We use the Aspose PDF java package to add stamps to each page of PDF files and found out that some graphics are lost with some PDF files.
Following is the sample code that reproduces the problem and attached are two sample files. In Sample_488.pdf the yellow rectangle at top gets lost and in Sample_492.pdf the black rectangle at top gets lost.
The operating system is Ubuntu 18.04. Java version is 1.8. Aspose PDF java package is 20.9
We were able to reproduce the issue in our environment and have logged it as PDFJAVA-39864 in our issue management system. We will surely investigate reasons behind it and will inform you as soon as it is resolved. Please be patient and give us some time.
We tested some sample files with PDF release 21.3, and verified that the graphics loss problem is resolved. But the new method (resizeContentsWithNormalization) fails with some other sample files with the following error. I uploaded the sample file (NullPointer_Sample.pdf).
java.lang.NullPointerException
at com.aspose.pdf.Operator.toString(Unknown Source)
at com.aspose.pdf.Operator.toString(Unknown Source)
at com.aspose.pdf.OperatorCollection.toString(Unknown Source)
at com.aspose.pdf.OperatorCollection.updateNormalizedData(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.resizeContents(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.resizeContents(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.resizeContentsWithNormalization(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.resizeContentsWithNormalization(Unknown Source)
at TestStamp.main(TestStamp.java:49)
Note that the old method (resizeContents) also has the graphics loss problem fixed and it does not have the NullPointerException problem.
We were able to replicate the issue in our environment with Aspose.PDF for Java 21.3. Therefore, a ticket as PDFJAVA-40415 has been logged in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.