Skip to content

Issue with Accented Characters in PDF Form Fields (checkbox and radiobutton) #4987

@JorjMcKie

Description

@JorjMcKie

Discussed in #4971

Originally posted by dantard April 20, 2026
Hello,

I'm working with a PDF file that includes form fields such as radio buttons and checkboxes. After a few hours of debugging, I identified a specific issue: when the on_state value of a checkbox or radio button contains accented characters, calling widget.update() fails. That is:

widget.field_value = True
widget.update()

throws:

File "/home/danilo/python-venv/lib/python3.12/site-packages/pymupdf/mupdf.py", line 53520, in pdf_set_field_value
    return _mupdf.pdf_set_field_value(doc, field, text, ignore_trigger_events)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: in method 'pdf_set_field_value', argument 3 of type 'char const *'

In my particular case, the on_state is set to S#ED, which is intended to represent “Sí”. This encoding seems to be the root of the problem.

From what I can tell, this may be related to how the PDF library or underlying encoding handles non-ASCII characters in form field values.

Has anyone encountered a similar issue? If so, how did you handle or work around it?

Any insights or suggestions would be appreciated.

Thanks is advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions