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

Free Support Forum - aspose.com

Convert image to PDF results in broken PDF

Hallo

I am using com.aspose.pdf in order to convert an image to a pdf. The problem is that the resulting pdf is broken.
The versin of aspose-pdf is 11.8.0

The code that I am using looks like this:

LicenseLoader licenseLoader = LicenseLoader.getInstance();
licenseLoader.loadLicenseForAsposePdf();
com.aspose.pdf.Image image = new com.aspose.pdf.Image();
image.setImageStream(new ByteArrayInputStream(imageData));
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
doc.getPages().add();
doc.getPages().get_Item(1).getPageInfo().setLandscape(false);
doc.getPages().get_Item(1).getParagraphs().add(image);
ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
doc.save(pdfStream);
pdfStream.toByteArray();

All the files used are added as attachment. The original image that I am using is named “testdoc.png”. The result pdf is named “testdoc.png.pdf” and the signed pdf is named “testdoc.pngSigned.pdf”.

If you open “testdoc.pngSigned.pdf” in acrobat reader, you will notice that a signature field is broken. After investigation on our side, we found out the cause:
- the problem is that “testdoc.png.pdf” contains 2 subsections.

See PDF specifications ISO 32000-1:2008(http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf) section 7.5.4: "For a file that has never been incrementally updated, the cross-reference section shall contain only one subsection"
The converted pdf(“testdoc.png.pdf”) contains 2 subsections. This has severe consequences on our product because signing results in broken signature fields, making the usage of aspose-pdf meaningless. This is a critical problem for our product.

Please let me know if there is anything unclear or if there are any updates on this.

Thank you,
Samuel

Hi Samuel,


Thanks for contacting support.

Can you please share the input signature file, so that we can test the scenario in our environment. The earlier shared code snippet specifies the steps to add an image to PDF format.

We will test the scenario and will reply accordingly.