File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -2749,7 +2749,7 @@ def _process_named_dests(dest: Any) -> None:
27492749 pag [NameObject ("/Annots" )] = lst
27502750 self .clean_page (pag )
27512751
2752- if "/AcroForm" in _ro and _ro ["/AcroForm" ] is not None :
2752+ if "/AcroForm" in _ro and not is_null_or_none ( _ro ["/AcroForm" ]) :
27532753 if "/AcroForm" not in self ._root_object :
27542754 self ._root_object [NameObject ("/AcroForm" )] = self ._add_object (
27552755 cast (
Original file line number Diff line number Diff line change @@ -2895,3 +2895,25 @@ def test_flatten_form_field_without_font_in_resources():
28952895 reader = PdfReader (b )
28962896 form_text_fields = reader .get_form_text_fields ()
28972897 assert form_text_fields ["Unique reference numberRow1" ] == "test"
2898+
2899+
2900+ def test_merge_with_null_acroform_does_not_raise_typeerror ():
2901+ """
2902+ Source PDFs may contain '/AcroForm null'.
2903+
2904+ Test for issue #3598.
2905+ """
2906+ src_writer = PdfWriter ()
2907+ src_writer .add_blank_page (72 , 72 )
2908+ src_writer .root_object [NameObject ("/AcroForm" )] = NullObject ()
2909+
2910+ src_bytes = BytesIO ()
2911+ src_writer .write (src_bytes )
2912+ src_bytes .seek (0 )
2913+
2914+ source = PdfReader (src_bytes )
2915+
2916+ target = PdfWriter ()
2917+ target .merge (0 , source )
2918+
2919+ assert "/AcroForm" not in target .root_object
You can’t perform that action at this time.
0 commit comments