This is what I want to do:
Make 2 different pdf files using pdfbox
Merge these two files together using pdfmerger
I know how
I use this to merge some documents (InputStreams) and write the merged document in a HttpServletResponse.
PDFMergerUtility mergedDoc = new PDFMergerUtility();
ByteArrayOutputStream colDocOutputstream = new ByteArrayOutputStream();
for (int i = 0; i < documentCount; i++)
{
ByteArrayOutputStream tempZipOutstream = new ByteArrayOutputStream();
...
mergedDoc.addSource(new ByteArrayInputStream(tempZipOutstream.toByteArray()));
}
mergedDoc.setDestinationStream(colDocOutputstream);
mergedDoc.mergeDocuments();
response.setContentLength(colDocOutputstream.size());
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=mergedDocument.pdf");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
response.addDateHeader("Expires", 0);
response.getOutputStream().write(colDocOutputstream.toByteArray());