Skip to content

update_page_form_field_values not updating already filled form fields #2034

@coolbombom

Description

@coolbombom

Hi

I'm trying to populate a PDF form, but when i call update_page_form_field_values it is not updating already filled form fields, see code below.

If i though run update_page_form_field_values with flags=1 (update_page_form_field_values(writer.pages[idx], form_fields, flags=1)) then the fields gets updated, but they become read only which is not usable in my case.

any help is appreciated

Environment

$ python -m platform
Linux-6.2.12-arch1-1-x86_64-with-glibc2.37

$ python -c "import PyPDF2;print(PyPDF2.__version__)"
3.0.1

Code

from PyPDF2 import PdfWriter

dst_file = "test_output.pdf"
writer = PdfWriter()
writer.append("test.pdf")
form_fields = {"Text Box 1":"test1"}
for idx,page in enumerate(writer.pages):
     writer.update_page_form_field_values(writer.pages[idx], form_fields)
with open(dst_file, "wb") as output_stream:
     writer.write(output_stream)
writer.close()

Traceback

no traceback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions