Last active
January 7, 2023 11:25
How to Change Page Size of PDF using Python. For more information: https://kb.aspose.com/pdf/python/how-to-change-page-size-of-pdf-using-python/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.pdf as pdf | |
# Source license and PDF files directory path | |
filePath = "C://Words//" | |
# Load the license in your application to modify the PDF page size | |
odpToPptxLicense = pdf.License() | |
odpToPptxLicense.set_license(filePath + "Conholdate.Total.Product.Family.lic") | |
# Open the source PDF file from the disk | |
pdfDocument = pdf.Document(filePath+"Output.pdf") | |
# Access the PDF page collection | |
pageCollection = pdfDocument.pages | |
# Access the second page | |
srcPage = pageCollection[1] | |
# Setting the page size as an Envelop (4.13 x 9.49 in) | |
# In Aspose.PDF, 1 inch = 72 points | |
# Therefore, Envelop dimensions in points will be (297.64, 683.15) | |
srcPage.set_page_size(297.64, 683.15) | |
# Save the PDF with the modified page size on the disk | |
pdfDocument.save(filePath + "GeneratedPdf.pdf") | |
print("Process completed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment