Skip to content

Commit c138f21

Browse files
authored
BUG: Clip by trimBox when merging pages, which would otherwise be ignored (#240)
Closes #163
1 parent d5a5eea commit c138f21

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

PyPDF2/pdf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,10 @@ def _mergePage(self, page2, page2transformation=None, ctm=None, expand=False):
23802380

23812381
page2Content = page2.getContents()
23822382
if page2Content is not None:
2383+
page2Content = ContentStream(page2Content, self.pdf)
2384+
page2Content.operations.insert(0, [map(FloatObject, [page2.trimBox.getLowerLeft_x(), page2.trimBox.getLowerLeft_y(), page2.trimBox.getWidth(), page2.trimBox.getHeight()]), "re"])
2385+
page2Content.operations.insert(1, [[], "W"])
2386+
page2Content.operations.insert(2, [[], "n"])
23832387
if page2transformation is not None:
23842388
page2Content = page2transformation(page2Content)
23852389
page2Content = PageObject._contentStreamRename(

0 commit comments

Comments
 (0)