Hi,
What PDFBox version are you using?
I tested it with the trunk and it works fine.
PDDocument doc = Loader.loadPDF(new File("XXX",
"interactiveform.pdf"));
PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
for (PDField field : acroForm.getFields())
{
field.setReadOnly(true);
}
doc.getDocumentCatalog().getAcroForm().flatten();
doc.save(new File("XXX", "interactiveform-saved.pdf"));
doc.close();
Btw using getFields() is not correct (see javadoc why)
Tilman
Am 22.02.2020 um 16:45 schrieb Aleksandar Simic:
Hello PDFBox users
I'm trying to flatten a PDF form so that it's no longer editable.
I can flatten the text fields, but the checkboxes are still editable
(you're able to check them).
I am doing this in Clojure, but that should not (I hope) do anything special
I get a PDF, get its forms and then I set them to read only.
Is there a step that I'm missing?
The code in question is here:
https://github.com/dotemacs/pdfboxing/commit/d62a3da18de258a5ca596b22cfa42d4552de9d60
The form I'm trying to edit is here:
https://github.com/dotemacs/pdfboxing/blob/flatten-form/test/pdfs/interactiveform.pdf
Thanks in advance
Aleksandar
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org