pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

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

Open jamoham opened this issue 7 years ago • 3 comments

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

jamoham avatar Nov 08 '16 01:11 jamoham

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

kherrett avatar Dec 14 '16 16:12 kherrett

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-

oceanicpanda avatar Apr 24 '17 07:04 oceanicpanda

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

mwhit74 avatar Sep 06 '17 18:09 mwhit74

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

pubpub-zz avatar May 28 '23 14:05 pubpub-zz