Losslessly changing the canvas size of a PDF

When handling PDF files, you might encounter situations where you need to modify the page dimensions without making changes to the content. This can be especially useful for adjusting a PDF for printing or other purposes. pdftocairo is a command-line utility that can help you accomplish this task effectively. In this guide, I’ll walk you through the process of modifying the page dimensions of a PDF using pdftocairo, with a specific example of resizing the page to A3.


Before you begin, ensure that you have the following prerequisites in place:

  • A Unix-like operating system, such as Linux.
  • The pdftocairo tool, which is part of the Poppler library. You can install poppler on Linux using your distribution’s package manager, such as apt, pacman, or xbps.


Open Your Command-Line Interface:

Begin by launching your terminal of choice on your Unix-like operating system.

Navigate to the Directory Containing Your PDF File:

Utilize the cd command to navigate to the folder where your PDF file is stored. If your file is in a folder called "documents", you can navigate there using the following command:

cd /path/to/my/documents 
Modify the Page Dimensions:

To adjust the page dimensions to A3, use the pdftocairo command with the -paper option. This option should be followed by the desired paper size and the filenames of the input and output files. In the example below, I’ll use "file.pdf" as the input file and "file_a3.pdf" as the output file:

pdftocairo -pdf -paper A3 file.pdf file_a3.pdf 
  • -pdf: This flag specifies the output format as PDF.
  • -paper: The paper option enables you to select the preferred paper size.
  • A3: Specifies the paper size as A3. You can choose from various standard paper sizes, such as A4, Letter, or Legal, and even define custom dimensions.
Execute the Command:

After entering the pdftocairo command, press Enter to execute it. pdftocairo will process the input PDF file and generate a new PDF file with the adjusted page dimensions.

Inspect the Output (important!):

Once the command has completed, you’ll find the modified PDF file with the updated page dimensions in your working directory. In this example, it will be named "file_a3.pdf." You can open it with a PDF viewer, such as zathura, to confirm that the page dimensions have been changed to A3 without affecting the content.