Skip to content

Commit a22d96f

Browse files
committed
ENH: docs: Add documentation about flattening a PDF form
1 parent c54cc0c commit a22d96f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/user/forms.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ writer.update_page_form_field_values(
3030
writer.pages[0],
3131
{"fieldname": "some filled in text"},
3232
auto_regenerate=False,
33+
flatten=False,
3334
)
3435

3536
with open("filled-out.pdf", "wb") as output_stream:
@@ -41,6 +42,12 @@ parameter is `True` by default for legacy compatibility, but this flags the PDF
4142
processor to recompute the field's rendering, and may trigger a "save changes"
4243
dialog for users who open the generated PDF.
4344

45+
If you want to flatten your form, that is, keeping all form field contents while
46+
removing the form fields themselves, you can set `flatten=True` to convert form
47+
field contents to regular pdf content, and then use
48+
`writer.remove_annotations(subtypes="/Widget")` to remove all form fields. This
49+
will result in a flattened pdf.
50+
4451
## Some notes about form fields and annotations
4552

4653
PDF forms have a dual-nature approach to the fields:

0 commit comments

Comments
 (0)