Closed alexey-v-paramonov closed 9 months ago
Thanks for the report. Do you want to submit a corresponding PR?
@stefan6419846 Sure, done: https://github.com/py-pdf/pypdf/pull/2280
This form is odd : the failing field is not referenced in any page... so can't be filled... The french administration has found a technical way to complexify "papers" and not to pay what they should ?😳🤣🤣🤣🤣🤣
I am using "Master PDF editor" for windows and I can not find a way to remove that field from the PDF. Can anyone give an idea what editor for Linux/Windows may help me to get rid of this invalid form field in the ACRE.pdf
?
Sorry but I dislike the idea of modifying an official form. The change you are proposing to cope with missing fields to build the states sounds better
@pubpub-zz well I am using a custom modified version of ACRE form in my project, so for me (while the fix is not accepted yet) removing that field completely from the PDF would help a lot.
Has been fixed in #2280.
Replace this: What happened? What were you trying to achieve?
Exception in a document that has radio buttons;
KeyError: '/_States_'
Environment
Which environment were you using when you encountered the problem?
Code + PDF
This is a minimal, complete example that shows the issue:
Share here the PDF file(s) that cause the issue. The smaller they are, the better. Let us know if we may add them to our tests!
ACRE.pdf
Traceback
This is the complete Traceback I see:
Proposal
Here: https://github.com/py-pdf/pypdf/blob/main/pypdf/_reader.py#L650C24-L650C24
retval
should be initialized, cause it may happen that element (radio btn) does not have any states, like so: