-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-formsFrom a users perspective, forms is the affected feature/workflowFrom a users perspective, forms is the affected feature/workflow
Description
When upgrading to 6.2.0 I noticed there was an UnboundLocalError when processing a pdf with a /Sig field. It does produce a warning 'Signature forms not implemented yet' but I didn't expect it to crash
Environment
$ python -m platform
Linux-6.8.0-90-generic-x86_64-with-glibc2.39
$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==6.6.2, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=12.1.0Code + PDF
import io
import pypdf
writer = pypdf.PdfWriter(io.BytesIO(open("minimal_signature.pdf", "rb").read()))
for page in writer.pages:
writer.update_page_form_field_values(
page,
# {"signature": "blah", "date": "xxx"},
{"signature": "ddd",},
auto_regenerate=False,
flatten=True
)
writer.write(open("op.pdf", "wb"))minimal_signature.pdf
(this can be added to tests)
Traceback
This is the complete traceback I see:
Signature forms not implemented yet
Traceback (most recent call last):
File "/home/johnsharp/scratch/pypdftest.py", line 7, in <module>
writer.update_page_form_field_values(
File "/home/johnsharp/code/pypdf/pypdf/_writer.py", line 1067, in update_page_form_field_values
if flatten and appearance_stream_obj is not None:
^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'appearance_stream_obj' where it is not associated with a value
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-formsFrom a users perspective, forms is the affected feature/workflowFrom a users perspective, forms is the affected feature/workflow