py-pdf / pypdf

A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files
https://pypdf.readthedocs.io/en/latest/
Other
8.29k stars 1.4k forks source link

Fields created by updatePageFormFieldValues do not show in Adobe Acrobat and Foxit #300

Closed jamoham closed 1 year ago

jamoham commented 7 years ago

I am using the following code to update the form fields with a dictionary:

from PyPDF2 import PdfFileReader, PdfFileWriter

reader = PdfFileReader(open("template_acrobat.pdf", "rb"), strict=False)
writer = PdfFileWriter()
writer.appendPagesFromReader(reader)
writer.updatePageFormFieldValues(writer.pages[0], dictionary_of_values)

with open("pdf_out.pdf", "wb") as f:
    writer.write(f)

The outputted PDF file does not show any form fields when opened in Adobe Acrobat or Foxit. Only when we click on a field, the data is shown. Also, It does not show when we print the PDF.

Please refer the attachment: Open the file in Adobe Acrobat and click on the 'Name' field in the PDF

pdf_out.pdf

kherrett commented 7 years ago

I'm seeing the same behavior. Any updates to this?

oceanicpanda commented 7 years ago

It would appear this behaviour doesn't just happen with PyPDF2 and may be a bug within adobe or the pdf itself? https://fnu.zendesk.com/hc/en-us/articles/201807773-Why-are-my-PDF-forms-not-showing-filled-in-form-fields-unless-I-click-on-them-

mwhit74 commented 7 years ago

See here: https://github.com/mstamy2/PyPDF2/issues/355

pubpub-zz commented 1 year ago

in order to copy properly the fields tree in the pdf file you need to use append() and not append_pages_from_reader()

This issue should be closed