Doc.save() fails with null pointer exception while saving a pdf

Hi @alexey.noskov, No still i am getting this error
Exception occured while calculating summary of the page java.lang.RuntimeException: java.lang.NullPointerException
Exception in thread “main” java.lang.IllegalArgumentException: The reference node is not a child of this node.
at com.aspose.words.CompositeNode.zzZp8(Unknown Source)
at com.aspose.words.CompositeNode.insertAfter(Unknown Source)
at Template2.main(Template2.java:77)

@sindhuV Could you please share your updated code? I will check it and provide you more information.

Hi @alexey.noskov. It is the updated code.Template3.zip (1.6 KB)

@sindhuV I have tested your code once again and it works fine on my side with both 19.10 and 21.12 versions of Aspose.Words for java. Please see the attached template and output document produced by your code on my side. template2.docx (15.0 KB)
template111.docx (10.6 KB)

Hi @alexey.noskov, One last question are you using oracle jdk or amazon coretto jdk?

@sindhuV I use oracle jdk on my side.

@alexey.noskov is there any chance the jdk affects this?

@sindhuV I have tested the code with amazon corretto JDK and the code still works as expected on my side. image.png (21.8 KB)

Hi @alexey.noskov
I just wanted to know why these warnings are shown and how I can resolve them
Template: MINOR_FORMATTING_LOSS: [LAYOUT] - Table column widths may need to be calculated. Rendered column widths could differ.
At Table 3, Section 1

Template: MINOR_FORMATTING_LOSS: [PDF] - Transparency does not conform to PDF/A standard and has been removed.

@sindhuV

This warning indicates that the Table with missing or invalid grid encountered or fit to content option set. In this case Aspose.Words needs to recalculate the grid. Table grid algorithm is not perfect yet and Aspose.Words warns that minor formatting loss might occur.

This warning clearly describes what happens. PDF/A standard does not allow using content with transparency. Aspose.Words make such content opaque to make the output document conform the PDF/A standard.

Thanks @alexey.noskov, is there any method we can use to recalculate the grid from aspose.words?

@sindhuV You can use Document.updateTableLayout method to recalculate tables grid. But it is strongly not recommended to use this method, because the algorithm used in this method can destroy layout of some tables.
While document layout, Aspose.Words uses different more accurate table grid calculation algorithm, which gives correct result in most cases.