pypdf
pypdf copied to clipboard
Fields created by updatePageFormFieldValues do not show in Adobe Acrobat and Foxit
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
I'm seeing the same behavior. Any updates to this?
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-
See here: https://github.com/mstamy2/PyPDF2/issues/355
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