When fields created with Aspose PDF call to Field.flatten() causes NullPointerException. Sample code is attached
Hi John,
Thanks for your inquiry. I have tested your shared code and noticed the reported exception. For further investigation, I have logged an issue in our issue tracking system as PDFJAVA-36096 and also linked your request to it. We will keep you updated via this thread regarding the issue status.
We are sorry for the inconvenience caused.
<span style=“font-size:10.0pt;line-height:115%;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:Calibri;color:#333333;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Best Regards,
Hi John,
Hi John,
Document pdf = new Document();<o:p></o:p>
pdf.getPages().insert(1);
TextBoxField field1 = new TextBoxField(pdf, new Rectangle(0, 0, 100, 100));
field1.setPartialName("FIELD1");
field1.setValue("FIELD1 VALUE");
pdf.getForm().add(field1, 1);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
pdf.save(stream);
Document pdf2 = new Document(new ByteArrayInputStream(stream.toByteArray()));
for (Field field : pdf2.getForm().getFields()) {
field.flatten();
}
java.io.OutputStream out = new FileOutputStream(myDir+"output.pdf");
pdf2.save(out);
Document docNew = new Document();
Page page = docNew.getPages().add();
FloatingBox box = new FloatingBox(100, 100);
box.setLeft(0);
box.setTop(page.getPageInfo().getHeight() - 100);
box.getParagraphs().add(new TextFragment(“FIELD1 VALUE”));
page.getParagraphs().add(box);
docNew.save(myDir+“output2.pdf”);