Concatenate PDF Documents
Multiple PDF documents can be merged or concatenated together into a a single PDF file. Just instantiate the PdfFileEditor object and call its concatenate method to acomplish this task. Concatenate method will take an array of streams (holding all input PDF files as streams) that are needed to be merged and a single stream object that will store the resulting PDF file after concatenation.
Multiple PDF documents can be merged or concatenated together into a a single PDF file. Just instantiate the PdfFileEditor object and call its concatenate method to acomplish this task. Concatenate method will take an array of streams (holding all input PDF files as streams) that are needed to be merged and a single stream object that will store the resulting PDF file after concatenation.
[Java]
try { //read the input file String inFile1 = "example1.pdf"; String inFile2 = "example2.pdf"; String outFile = "kitOut1.pdf"; FileInputStream inStream1 = new FileInputStream(inFile1); FileInputStream inStream2 = new FileInputStream(inFile2); //concatenate two files FileOutputStream outputStream = new FileOutputStream(outFile); PdfFileEditor editor = new PdfFileEditor(); editor.concatenate(inStream1, inStream2, outputStream); //close the output FileOutputStream outputStream.close(); } catch (Exception ex) { System.out.println(ex.getMessage()); }
PdfFileEditor class has three overloaded methods of concatenate that can be used by developers according to their needs.
