Skip to content

Commit 2f1b18d

Browse files
Cimon Lucas (LCM)Cimon Lucas (LCM)
authored andcommitted
Adding a .Pages attribute in PdfWriter to allow setting its MediaBox or Resources fields
1 parent 6c89216 commit 2f1b18d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pdfrw/pdfwriter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def __init__(self, fname=None, version='1.3', compress=False, **kwargs):
262262
"on PdfWriter instance" % name)
263263
setattr(self, name, value)
264264

265+
self.Pages = None
265266
self.pagearray = PdfArray()
266267
self.killobj = {}
267268

@@ -310,14 +311,14 @@ def _get_trailer(self):
310311
self.make_canonical()
311312

312313
# Create the basic object structure of the PDF file
314+
pages = self.Pages or IndirectPdfDict()
315+
pages.Type = PdfName.Pages,
316+
pages.Count = PdfObject(len(self.pagearray)),
317+
pages.Kids = self.pagearray
313318
trailer = PdfDict(
314319
Root=IndirectPdfDict(
315320
Type=PdfName.Catalog,
316-
Pages=IndirectPdfDict(
317-
Type=PdfName.Pages,
318-
Count=PdfObject(len(self.pagearray)),
319-
Kids=self.pagearray
320-
)
321+
Pages=pages,
321322
)
322323
)
323324
# Make all the pages point back to the page dictionary and

0 commit comments

Comments
 (0)