How to Resize a PDF in Python

Due to their versatile but static nature, PDFs are often utilized by businesses to share information with clients and customers. Many of these documents begin in another format, such as PPTX or DOCX, and are converted to PDF for increased compatibility and security. In Europe and much of the world, the standard PDF size is A4 (210mm x 297mm), and in the US it’s Letter size (8.5in x 11in). If you need to print a PDF in a size other than standard, the following API will help you resize your PDF to meet your requirements.

Image for post
Image for post

Our first step is to install the client software:

pip install cloudmersive-convert-api-client

Then, we can add the imports and call the function with the following code:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from import ApiException
from pprint import pprint

This tool will allow you to automatically set parameters for PDF printing size when appropriate. To retrieve your personal API key, head to the Cloudmersive website to register for a free account and gain access to 800 API calls/month.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store