File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1183,8 +1183,13 @@ def _merge_page_writer(
1183
1183
pdf = self .indirect_reference .pdf
1184
1184
1185
1185
rename = {}
1186
+ if PG .RESOURCES not in self :
1187
+ self [NameObject (PG .RESOURCES )] = DictionaryObject ()
1186
1188
original_resources = cast (DictionaryObject , self [PG .RESOURCES ].get_object ())
1187
- page2resources = cast (DictionaryObject , page2 [PG .RESOURCES ].get_object ())
1189
+ if PG .RESOURCES not in page2 :
1190
+ page2resources = DictionaryObject ()
1191
+ else :
1192
+ page2resources = cast (DictionaryObject , page2 [PG .RESOURCES ].get_object ())
1188
1193
1189
1194
for res in (
1190
1195
RES .EXT_G_STATE ,
Original file line number Diff line number Diff line change @@ -1227,6 +1227,16 @@ def create_stamp_pdf() -> BytesIO:
1227
1227
)
1228
1228
1229
1229
1230
+ def test_merge_with_no_resources ():
1231
+ """Test for issue #2147"""
1232
+ writer = PdfWriter ()
1233
+ p0 = writer .add_blank_page (900 , 1200 )
1234
+ del p0 ["/Resources" ]
1235
+ p1 = writer .add_blank_page (900 , 1200 )
1236
+ del p1 ["/Resources" ]
1237
+ writer .pages [0 ].merge_page (p1 )
1238
+
1239
+
1230
1240
def test_get_contents_from_nullobject ():
1231
1241
"""Issue #2157"""
1232
1242
writer = PdfWriter ()
You can’t perform that action at this time.
0 commit comments