We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mergeing pdfs doesn't work!

I need to merge 2 different PDFs to 1. I tried append method from com.aspose.pdf.kit.PdfFileEditor but it doesn’t work. Following is my code:


File target = PDFUtil.createTempFile();
FileOutputStream os = new FileOutputStream(target);
FileInputStream inpuStream1= new FileInputStream(f1);
FileInputStream inpuStream2= new FileInputStream(f2);
com.aspose.pdf.kit.PdfFileEditor editor = new com.aspose.pdf.kit.PdfFileEditor();
editor.append(inputStream1, portStream2, 1, 1, os);
os.flush();

I am pretty sure both f1 and f2 are valid pdf because I tried to concatenated them by “pdfDocument.getPages().add(addPageDocument.getPages())” it can successfully glued 2 PDFs in seprate pages but I need merge them into 1 pdf.

Hi Edward,

Thank you for contacting support. You are using Aspose.Pdf.Kit for Java API which was discontinued as a separate product. You might come across the problem which need to be fixed, but we do not provide fixes in the old code bases. The same PdfFileEditor class is available in com.aspose.pdf.facades package with the latest version 17.4 of Aspose.Pdf for Java API. We recommend you to download and try the latest version 17.4 of Aspose.Pdf for Java API. Please refer to this help topic: Migration from legacy Aspose.Pdf.Kit for Java

I tried append method from com.aspose.pdf.kit.PdfFileEditor but it doesn’t work.

Does it show an error? Please share details of the problem. Your response is awaited.

Hello Rafique,


I tried com.aspose.pdf.facades.PdfFileEditor. It’s won’t cause any exception in java code but it generated an invalid PDF. The error message is following:

Adobe Acrobat Reader could not open ‘filename.pdf’ because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn’t correctly decoded).

Thanks,
Edward

Hi Edward,


Thanks for sharing the details.

Can you please share the input PDF files, so that we can test the scenario in our environment. Also please share some details regarding your working environment i.e. Operating System, JDK version etc.