@JD OConal, thanks for the help, the article you sent me was very outdated, but it pointed me to iText. I found this page that explains how to do exactly what I need: http://java-x.blogspot.com/2006/11/merge-pdf-files-with-itext.html
Thanks for the other answers, but I really do not want to start other processes if I can avoid this and our project already has itext.jar, so I am not adding any external dependencies
Here is the code I wrote:
public class PdfMergeHelper { public static void concatPDFs(List<InputStream> streamOfPDFFiles, OutputStream outputStream, boolean paginate) { Document document = new Document(); try { List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new ArrayList<PdfReader>(); int totalPages = 0; Iterator<InputStream> iteratorPDFs = pdfs.iterator();
source share