You can use this library to merge a bunch of PDF documents.
Code would be something like (taken from the PKN project):
// assume metamodel object is called = SomeDocument;
// docs = input list of SomeDocument, ie. the documents that need to be merged;
import org.apache.pdfbox.util.PDFMergerUtility;
// BEGIN USER CODE
int i = 0;
PDFMergerUtility mergePdf = new PDFMergerUtility();
for(i=0; i < this.docs.size(); i++)
{
SomeDocument file = this.docs.get(i);
InputStream content = Core.getFileDocumentContent(this.getContext(), file.getMendixObject());
mergePdf.addSource(content);
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
mergePdf.setDestinationStream(out);
mergePdf.mergeDocuments();
SomeDocument returnDoc = SomeDocument.create(this.getContext());
Core.storeFileDocumentContent(this.getContext(), returnDoc.getMendixObject(), "Filename" , new ByteArrayInputStream(out.toByteArray()));
out.reset();
this.docs.clear();
return returnDoc.getMendixObject();
// END USER CODE