You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
for widget in widgets:
... logic to change the field value
widget.field_flags = fitz.PDF_FIELD_IS_READ_ONLY
widget.update()
and to delete it:
for widget in widgets:
widget.field_value = fields[widget.field_name] # type: ignore
widget.field_flags = fitz.PDF_FIELD_IS_READ_ONLY
widget.update()
page.delete_widget(widget)
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)
Windows 10 and arch linux
Python 3.11
PyMuPDF 1.22.5, installation method by pyproyect.toml.
The text was updated successfully, but these errors were encountered:
Deleting a widget, in general cannot be prevented by setting a field read-only.
That flag only prevents the widget being changed. You can still delete it independently from this.
Otherwise, I don't understand:
If you delete a widget, then it will be gone - together with everything associated.
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.
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:
for widget in widgets:
... logic to change the field value
widget.field_flags = fitz.PDF_FIELD_IS_READ_ONLY
widget.update()
and to delete it:
for widget in widgets:
widget.field_value = fields[widget.field_name] # type: ignore
widget.field_flags = fitz.PDF_FIELD_IS_READ_ONLY
widget.update()
page.delete_widget(widget)
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)
The text was updated successfully, but these errors were encountered: