Update Page Dimensions in Python

Contents
[ ]

To update page Dimensions using Aspose.PDF Java for Python, simply invoke UpdatePageDimensions class.

Python Code

pdf = self.Document()
pdf=self.dataDir + 'input1.pdf'

# get page collection
page_collection = pdf.getPages()

# get particular page
pdf_page = page_collection.get_Item(1)

# set the page size as A4 (11.7 x 8.3 in) and in Aspose.PDF, 1 inch = 72 points
# so A4 dimensions in points will be (842.4, 597.6)
pdf_page.setPageSize(597.6,842.4)

# save the newly generated PDF file
pdf.save(self.dataDir + "output.pdf")

print "Dimensions updated successfully!"

Download Running Code

Download Update Page Dimensions (Aspose.PDF) from any of the below mentioned social coding sites: