Removal of widgets, text is lost #2574
-
When I use the method to delete all widgets from a PDF I lose all the text inside it, or when I use the widget.field_flags = fitz.PDF_FIELD_IS_READ_ONLY if I open the fields again they are editable. To Reproduce (mandatory)On read only fields, i save with this method: and to delete it: Expected behavior (optional)I expect text within a widget to be saved and the widget disappears or with the field flag when I reopen the PDF it's fields shouldn't be editable. Your configuration (mandatory)
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Deleting a widget, in general cannot be prevented by setting a field read-only. Otherwise, I don't understand: |
Beta Was this translation helpful? Give feedback.
-
The thing I want to do is a common PDF operation called flattening. What this does is combine all text into one layer, removing the widgets and making it more hard to edit so we can protect the information that was filled out in the form. I know pdftk does it and also applications like Adobe Acrobat Reader. This is mostly necessary to store the PDF file securely and increasing security on the document so it cannot be filled out later again. Is this possible in pymupdf? this is an exact example of flattening operation: https://pdfpro.com/blog/guides/how-to-flatten-a-pdf/ |
Beta Was this translation helpful? Give feedback.
-
In contrast to what the referenced article implies, the term "flattening" is not clearly defined. |
Beta Was this translation helpful? Give feedback.
-
okay, thank you very much for the help |
Beta Was this translation helpful? Give feedback.
In contrast to what the referenced article implies, the term "flattening" is not clearly defined.
Some people understand this as creating an image-only version for each page.
Otherwise, there is
doc.convert_to_pdf()
which also converts widgets and annotations to normal, standard PDF content. It also removes PDF Optional Content layers.