This is what I want to do:
Make 2 different pdf files using pdfbox
Merge these two files together using pdfmerger
I know how
You can use this way also:-
1) Create List of InputStream
2) Instantiate PDFMergerUtility class
3) Set Destination Output Stream
4) Add all InputStreams to PDFMerger as Source files which needs to be merged.
5) Merge the documents by calling "PDFmerger.mergeDocuments();
"
List locations=new ArrayList();
locations.add(new FileInputStream("E:/Filenet Project Support/MergePDFs_Sample_Code/Attorney_new_form.pdf"));
locations.add(new FileInputStream("E:/Filenet Project Support/MergePDFs_Sample_Code/JH.pdf"));
locations.add(new FileInputStream("E:/Filenet Project Support/MergePDFs_Sample_Code/Interpreter_new_form.pdf"));
//Instantiating PDFMergerUtility class
PDFMergerUtility PDFmerger = new PDFMergerUtility();
//Setting Destination Output Stream
OutputStream out = new FileOutputStream("E:/Filenet Project Support/MergePDFs_Sample_Code/merged.pdf");
//Adding all InputStreams to PDFMerger as Source files which needs to be merged.
PDFmerger.addSources(locations);
//Setting Destination Output Stream
PDFmerger.setDestinationStream(out);
//Merging the two documents
PDFmerger.mergeDocuments();
System.out.println("Documents merged");