Hi,
We are using aspose.pdf(ver 10.2.0 ) for adding an image to the existing pdf.
Its not giving any error while adding the image to the pdf but when i try to save the modified pdf it gave me null point error as shown below trace.
Line# 191 pdfDocument.save(pdfGenFilePath);//here it gives error
below line is for setting the image inputstream.
image.setImageStream(inputImg);//here inputImg path is not correct or file doesnt exist
How to handle this scenario, expecting it has to warn while adding empty/corrupted image instead of during save the pdf file.
Please suggest a workaround.
=================ERROR==================
java.lang.NullPointerException
at com.aspose.pdf.Image.m1(Unknown Source)
at com.aspose.pdf.Image.m1(Unknown Source)
at com.aspose.pdf.z59.m5(Unknown Source)
at com.aspose.pdf.Cell.m1(Unknown Source)
at com.aspose.pdf.Row.m1(Unknown Source)
at com.aspose.pdf.Row.m1(Unknown Source)
at com.aspose.pdf.Table.m1(Unknown Source)
at com.aspose.pdf.z59.m5(Unknown Source)
at com.aspose.pdf.Page.m2(Unknown Source)
at com.aspose.pdf.Page.processParagraphs(Unknown Source)
at com.aspose.pdf.ADocument.processParagraphs(Unknown Source)
at com.aspose.pdf.Document.processParagraphs(Unknown Source)
at com.aspose.pdf.ADocument.saveInternal(Unknown Source)
at com.aspose.pdf.Document.saveInternal(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
at my.pdf.utility.PDFGenerator.generatePDF(PDFGenerator.java:191)
at my.pdf.utility.PDFGenerator.main(PDFGenerator.java:274)
Process exited with exit code 0.
Hi Hana,
This issue is not happening in all the time, only few cases, assuming that the image addition/loading is not correct hence it throws error while saving the updated pdf document.
I have already added the snippet in my description of the issue.
Please let me know if you still need more details.
Thanks.
Hi Hana,
Hi,
We are facing this issue intermittently, and not always with same place or same document.
I feel, when it try to add one image, if that image is taking bit delay reading from filesystem, then aspose is not adding properly, when we save that document then its failing with said exception.
As its api trace, we are not able to identify exactly what it is trying and failed.
when we try the same document, same scenario it works.
If you required, more details of trace I can share, but as its not specific to a document or an image, i could not provide the source.
We are running the application on Linux machines, and jdk version we used is jdk1.7.0_85.
Please let me know if more details required.
Thanks.
Hi Hana,