Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update_page_form_field_values prevents barcode (pdf417) from displaying correctly #1306

Closed
BenjaminFarris opened this issue Aug 30, 2022 · 1 comment · Fixed by #1864
Closed
Labels
Has MCVE A minimal, complete and verifiable example helps a lot to debug / understand feature requests is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-forms From a users perspective, forms is the affected feature/workflow

Comments

@BenjaminFarris
Copy link

BenjaminFarris commented Aug 30, 2022

Here's a description of the issue
https://stackoverflow.com/questions/73533672/pypdf2-doesnt-display-barcode-pdf417-after-using-update-page-form-field-value/73535421#73535421

pdf417 barcode isn't displayed after using update_page_form_field_values()

Environment

Which environment were you using when you encountered the problem?

  • Windows 10
  • Visual Studio Code
  • python 3.10.6
$ python -m platform
Windows-10-10.0.19043-SP0

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

Code + PDF

This is a minimal, complete example that shows the issue:

from PyPDF2 import PdfReader, PdfWriter


reader = PdfReader("i-130.pdf", strict=True)
pager = reader.pages[0]
field_dict = {"Pt2Line4b_GivenName[0]": "Mark"}

writer = PdfWriter(strict=True)
writer.add_page(pager)
writer.update_page_form_field_values(pager, fields=field_dict)

with open("newfile.pdf", "wb") as fh:
    writer.write(fh)

The PDF: https://www.uscis.gov/sites/default/files/document/forms/i-130.pdf - you can add it to the tests

The issue

It works, just doesn't work correctly

@BenjaminFarris BenjaminFarris changed the title update_page_form_field_values prevents barcode (pdf417 from displaying correctly update_page_form_field_values prevents barcode (pdf417) from displaying correctly Aug 30, 2022
@MartinThoma MartinThoma added is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-forms From a users perspective, forms is the affected feature/workflow Has MCVE A minimal, complete and verifiable example helps a lot to debug / understand feature requests labels Aug 31, 2022
@pubpub-zz
Copy link
Collaborator

Currently , when you are using update_page_form_field_values() you are setting the flag NeedAppearances to true which is asking the viewer to regenerate the appearances of the fields when opening the file : this mean that the "field" of the code is regenerated.

I've started a PR to prepare a fix to not set the NeedAppearances flag but generate the fields Appearance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has MCVE A minimal, complete and verifiable example helps a lot to debug / understand feature requests is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-forms From a users perspective, forms is the affected feature/workflow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants