Merged Pdf file is corrupt

Hi,


I am using MergePdf.java in the attached zip to merge multiple pdf files. When I try to merge the file input1.pdf in the attached zip, the output is corrupted and throws an error, the file is damaged and could not be repaired. If I concatenate one more input1.pdf to the merged pdf, then the output is proper.
I am using Aspose Pdf Kit for Java version 3.4.0. I had tried with the latest version of 4.3.0 also. The same issue persists there also.

Can you please get back with a solution for the above issue ?

Thanks,
Mani
(Zoho Corp).

Hi Mani,

Thanks for using our products.

I have gone through the problem description and the code snippet that you have shared and as per my observations, you are trying to concatenate input1.pdf file with other PDF files and the resultant PDF is always corrupted. In order to test the scenario, I have used the following code snippet where I have first created the copy of input1.pdf and tried concatenating it with input1.pdf. During my testing with Aspose.Pdf.Kit for Java 4.3.0, I am unable to notice any problem in the resultant document.

[Java]

//read the input file
String inFile1 = "D:/pdftest/mergepdf/input1.pdf";
String inFile2 = "D:/pdftest/mergepdf/input1-
Copy.pdf";
String outFile = "D:/pdftest/mergepdf/Merged_Output.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();

Can you please share some further details which can help us in replicating this problem.

PS, By the way, I did not notice that you have closed the output stream in your code, as highlighted above.

Hi,


Sorry I was not clear. I am trying to create a pdf file from one pdf file(input1.pdf). The args will have 2 args only - One input, one output. In that case it works for certain files and not working for certain files.

Thanks,
Mani.

Hi Mani,


Thanks for sharing the details.

Can you please share the sample PDF documents that are causing the problem so that we can test the scenario at our end. We are sorry for your inconvenience.