- There is an error when saving such a flatened file. The file is still created, but is still fillable (ie there are still forms).
- If we copy the fltaned PDF into another one, it save withour problem, but is still fillable (ie there are still forms).
Test code :
- Code: Select all
//Create a PdfDocument instance and load
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile("./data/test_input.pdf");
//Flatten all the forms in the document
pdf.getForm().isFlatten(true);
//copy in another pdf and save the result
System.out.println("saving duplicate after flattening");
PdfDocument pdf2 = new PdfDocument();
pdf2.appendPage(pdf);
pdf2.saveToFile("./data/test_copy.pdf");
//Save the result document
System.out.println("saving initial after flattening");
pdf.saveToFile("./data/test_output_flattened.pdf");
The result is an error :
Exception in thread "main" java.lang.NullPointerException: while trying to invoke the method com.spire.pdf.graphics.PdfFont.getFontFamily() of a null object loaded from local variable 'a'
OS : Microsoft Windows Server 2016 Datacenter
Java version : version 1.8.0_351 by SAP AG
PDF/Office version :
I:spire.office for java - version 9.1.4 by E-iceblue Co., Ltd.
I:spire.doc for java - version 12.1.10 by E-iceblue Co., Ltd.
Regards