This topic describes how to zoom PDF using Python. You will get the details of setting the environment for developing the application, a list of steps, and a sample code to apply PDF Zoom Out using Python. It will describe the details of setting the target page and position in the PDF file.
Steps to Zoom PDF File using Python
- Set the environment to use Aspose.PDF for Python via .NET for zooming PDF on open
- Load the target PDF file into the Document class object for the custom zoom level
- Create the destination by setting the page number, zoom offset, and zoom level
- Create the action with the above destination
- Set the open_action property of the loaded document
- Save the output PDF file with a custom zoom level
These steps summarize the process to zoom out PDF using Python. Load the target PDF file, create the destination with page number, top-left position, and zoom level, create an action with this destination, and set this action to the PDF document. Save the output PDF file and test it by opening it in Acrobat Reader.
Code for Setting PDF Zoom Size using Python
This code shows how to apply PDF Zoom in using Python. The ‘aspose.pdf.annotations’ namespace includes the XYZExplicitDestination class, which accepts a zero-indexed page number, the offset from the top-left corner of the selected page, and the zoom level. The zoom value of 1.25 results in a 125% zoom level, and the top value of 250 will zoom to 150 points above the selected page.
This article has guided us to zoom PDF file with Python. To change the opening settings of the PDF file, refer to the article on Change PDF settings to open in Adobe using Python.