Skip to content

Commit

Permalink
DOC: Notes about update_page_form_field_values(auto_regenerate) (#2359)
Browse files Browse the repository at this point in the history
Co-authored-by: dmjohnsson23 <[email protected]>
  • Loading branch information
MartinThoma and dmjohnsson23 authored Dec 23, 2023
1 parent 0a79b3c commit 0748a92
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/user/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@ writer = PdfWriter()

page = reader.pages[0]
fields = reader.get_fields()
print(fields)

writer.append(reader)

writer.update_page_form_field_values(
writer.pages[0], {"fieldname": "some filled in text"}
writer.pages[0],
{"First Name": "some filled in text"},
auto_regenerate=False,
)

# write "output" to pypdf-output.pdf
with open("filled-out.pdf", "wb") as output_stream:
writer.write(output_stream)
```

Generally speaking, you will always want to use `auto_regenerate=False`. The
parameter is `True` by default for legacy compatibility, but this flags the PDF
Viewer to recompute the field's rendering, and may trigger a "save changes"
dialog for users who open the generated PDF.

0 comments on commit 0748a92

Please sign in to comment.