Am 22.02.2020 um 18:33 schrieb Aleksandar Simic:
Hello Tilman

On Sat, Feb 22, 2020 at 4:08 PM Tilman Hausherr <thaush...@t-online.de>
wrote:

What PDFBox version are you using?

I was using 2.0.16
https://github.com/dotemacs/pdfboxing/blob/flatten-form/project.clj#L7

I tested it with the trunk and it works fine.
Here is my Java code:
https://gist.github.com/ff9fb8ccf11abeb2ac6c1c461f2c1eb9

Compiled it with PDFBox 2.0.18 and commons-logging 1.1.2.

Opening it in macOS' Preview PDF viewer, I can still check the checkboxes.
But *not* in Adobe's Acrobat Reader DC version 2020.006.20034.

The upgraded the Clojure project and the behaviour is the same:
- I can check the checkboxes in Preview
- I can't check the checkboxes in Acrobat Reader DC

What PDF viewer did you use to verify the flattening ?


Adobe Reader DC.

Here's my result file:

http://www.filedropper.com/interactiveform-saved

I looked with PDFDebugger, there are no more checkbox fields.

Please try with that file.

If my file brings the same effect, then I'd say this is a weird behavior of MacOS Preview. Maybe it transforms anything that looks like a checkbox into a field?



Btw using getFields() is not correct (see javadoc why)
Looking at:

https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.html#getFields--

(Note: 2.0.13 is the latest documentation linked from
https://pdfbox.apache.org/ )

Is the reason that .getFields returns only the top level fields and not the
nested ones?
So I'll have to loop through them to flatten all the child fields?


No, this is more a general observation. I don't think you have to set then readonly at all.

Tilman





Thank you for your time
Aleksandar


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



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to