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

Checkboxes, update_page_form_field_values, encoding and german characters. #2021

Closed
kubaPod opened this issue Jul 26, 2023 · 1 comment · Fixed by #2047
Closed

Checkboxes, update_page_form_field_values, encoding and german characters. #2021

kubaPod opened this issue Jul 26, 2023 · 1 comment · Fixed by #2047
Labels
workflow-forms From a users perspective, forms is the affected feature/workflow

Comments

@kubaPod
Copy link

kubaPod commented Jul 26, 2023

I am filling a form with text and checkbox fields. Text values may contain german characters.
If a checkbox is programmatically selected then subsequent fields are corrupted.
It might not be a pypdf fault, see viewers comparison in caveats below.

image vs. image

Caveats:

  • if the corrupted field gets focus the displayed text is correct ( back to incorrect when the focus is lost):
    image

  • case reproduced in Adobe Acrobat Reader

  • Chrome viewer shows correct characters:
    image

  • Firefox viewer shows incorrect characters (even in the first field) regardless of checkbox:
    image

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Windows-10-10.0.19045-SP0

$ python -c "import pypdf;print(pypdf.__version__)"
3.12.2

Code + PDF

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

from pypdf import PdfWriter

writer = PdfWriter()
writer.append("./visa-form.pdf")

writer.update_page_form_field_values(
    writer.pages[0],
    {
        '1 Surname': 'Zürich', 
    #    'Check Box 9.1': '/Ja',  # skip or not
        '9': 'Zürich'
    }    
)

with open("./zurich-test.pdf", "wb") as output_stream:
    writer.write(output_stream)
    output_stream.close()

visa-form.pdf
zurich-test-no-checkbox.pdf
zurich-test-with-checkbox.pdf

Traceback


TODO

@kubaPod kubaPod changed the title Checking checkboxes interferes with subsequent text fields' encoding. Checkboxes, update_page_form_field_values, encoding and german characters. Jul 26, 2023
pubpub-zz added a commit to pubpub-zz/pypdf that referenced this issue Jul 30, 2023
@pubpub-zz
Copy link
Collaborator

@kubaPod,
the issue deals with the encoding
I've proposed a PR if you want to try.

@MartinThoma MartinThoma added the workflow-forms From a users perspective, forms is the affected feature/workflow label Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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