Question

How to merge the multiple PDF files into the Single PDF in Pega?
Hi,
I need to merge the multiple PDF files into the Single PDF.
As there is no OOTB function for this, the custom functions have to be created.
Please share if there is any logic for this.
Thanks
-
Like (0)
-
Accepted Solution

Please refer below code,
Please refer below code,

I have the sample Java code which is being used along with apache PDFBox library.
The temp files to created in place of taking the actual files in the following code.
I have the sample Java code which is being used along with apache PDFBox library.
The temp files to created in place of taking the actual files in the following code.
import org.apache.pdfbox.multipdf.PDFMergerUtility; import org.apache.pdfbox.pdmodel.PDDocument; import java.io.File; import java.io.IOException; public class MergePDFs { public static void main(String[] args) throws IOException { //Loading an existing PDF document File file1 = new File("C:/PdfBox_Examples/sample1.pdf"); PDDocument doc1 = PDDocument.load(file1); File file2 = new File("C:/PdfBox_Examples/sample2.pdf"); PDDocument doc2 = PDDocument.load(file2); //Instantiating PDFMergerUtility class PDFMergerUtility PDFmerger = new PDFMergerUtility(); //Setting the destination file PDFmerger.setDestinationFileName("C:/PdfBox_Examples/merged.pdf"); //adding the source files PDFmerger.addSource(file1); PDFmerger.addSource(file2); //Merging the two documents PDFmerger.mergeDocuments(); System.out.println("Documents merged"); //Closing the documents doc1.close(); doc2.close(); } }

Hi Krishna,
You can refer to below articles, which will help you.
https://community.pega.com/support/support-articles/merging-two-pdf-documents
https://community.pega.com/support/support-articles/using-itext-merging-two-pdf
Hi Krishna,
You can refer to below articles, which will help you.
https://community.pega.com/support/support-articles/merging-two-pdf-documents
https://community.pega.com/support/support-articles/using-itext-merging-two-pdf
Accepted Solution

Please refer below code,
Please refer below code,