Skip to content

Commit

Permalink
Adding a .Pages attribute in PdfWriter to allow setting its MediaBox …
Browse files Browse the repository at this point in the history
…or Resources fields
  • Loading branch information
Cimon Lucas (LCM) authored and Cimon Lucas (LCM) committed Jul 20, 2020
1 parent 6c89216 commit 2f1b18d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pdfrw/pdfwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def __init__(self, fname=None, version='1.3', compress=False, **kwargs):
"on PdfWriter instance" % name)
setattr(self, name, value)

self.Pages = None
self.pagearray = PdfArray()
self.killobj = {}

Expand Down Expand Up @@ -310,14 +311,14 @@ def _get_trailer(self):
self.make_canonical()

# Create the basic object structure of the PDF file
pages = self.Pages or IndirectPdfDict()
pages.Type = PdfName.Pages,
pages.Count = PdfObject(len(self.pagearray)),
pages.Kids = self.pagearray
trailer = PdfDict(
Root=IndirectPdfDict(
Type=PdfName.Catalog,
Pages=IndirectPdfDict(
Type=PdfName.Pages,
Count=PdfObject(len(self.pagearray)),
Kids=self.pagearray
)
Pages=pages,
)
)
# Make all the pages point back to the page dictionary and
Expand Down

0 comments on commit 2f1b18d

Please sign in to comment.