Hi
We get null pointer exception for few docs while trying to apply textstamp (fontsize=10) iteratively for each page at the line where we call save() method of com.aspose.pdf.Document
Font font = FontRepository.findFont("Helvetica", true);
PageCollection pages = doc.getPages();
for (Page page : pages) {
writeToPage(font, fontSize, doc, page, stamp);
}
//writeToPage code snippet
TextStamp textStamp = new TextStamp(text);
int margin = 15;
// Set text alignment and margin based on page rotation
textStamp.setHorizontalAlignment(HorizontalAlignment.Right);
textStamp.setVerticalAlignment(VerticalAlignment.Top);
textStamp.setTopMargin(margin);
textStamp.setRightMargin(margin);
// set text properties
textStamp.getTextState().setFont(font);
textStamp.getTextState().setFontSize(fontSize);
// add stamp to particular page
page.addStamp(textStamp);
// save output document
doc.save();
java.lang.NullPointerException
at com.aspose.pdf.internal.l8f.l0v.lv(Unknown Source)
at com.aspose.pdf.internal.l9p.ld.lI(Unknown Source)
at com.aspose.pdf.internal.l8f.l0p.lf(Unknown Source)
at com.aspose.pdf.inteyrnal.l8f.l0t.lj(Unknown Source)
at com.aspose.pdf.internal.l0k.l0if.lh(Unknown Source)
at com.aspose.pdf.ADocument.l1n(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
Here are more details about the env where Aspose is integrated in.
The Aspose related services are exposed as REST calls packaged as web application
with the rest of the other services specific to project.
aspose-pdf-19.1-jdk17.jar
Oracle JDK 1.7.0_71
Jai_Codec 1.1.3
Springframework 4.0.1.RELEASE
Tomcat 7.0.39
RHEL 6.5
Best regards,
MansoorTest-A.pdf (37.0 KB)