noxz-sites

A collection of a builder and various scripts creating the noxz.tech sites
git clone https://noxz.tech/git/noxz-sites.git
Log | Files | README | LICENSE

noxz.tech/articles/lossless-pdf-canvas-size-modification/index.www
1When 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.
2.ICD pdftocairo
3is 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
4.ICD pdftocairo ,
5with a specific example of resizing the page to A3.
6
7.HnS 1
8Prerequisites
9.HnE
10
11Before you begin, ensure that you have the following prerequisites in place:
12
13.ULS
14.LI
15A Unix-like operating system, such as Linux.
16.LI
17The pdftocairo tool, which is part of the
18.URL "https://poppler.freedesktop.org/" "Poppler library" .
19You can install
20.ICD poppler
21on Linux using your distribution's package manager, such as
22.ICD apt ,
23.ICD pacman ,
24or
25.ICD xbps .
26.ULE
27
28
29.HnS 1
30Procedure
31.HnE
32
33.DLS
34.LI "Open Your Command-Line Interface:"
35Begin by launching your terminal of choice on your Unix-like operating system.
36
37.LI "Navigate to the Directory Containing Your PDF File:"
38Utilize 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:
39
40.CDS
41.COS
42cd /path/to/my/documents
43.COE
44.CDE
45
46.LI "Modify the Page Dimensions:"
47To adjust the page dimensions to A3, use the
48.ICD pdftocairo
49command with the
50.ICD -paper
51option. 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:
52
53.CDS
54.COS
55pdftocairo -pdf -paper A3 file.pdf file_a3.pdf
56.COE
57.CDE
58
59.ULS
60.LI
61.ICD -pdf :
62This flag specifies the output format as PDF.
63.LI
64.ICD -paper :
65The paper option enables you to select the preferred paper size.
66.LI
67.ICD A3 :
68Specifies the paper size as A3. You can choose from various standard paper sizes, such as A4, Letter, or Legal, and even define custom dimensions.
69.ULE
70
71.LI "Execute the Command:"
72After entering the
73.ICD pdftocairo
74command, press Enter to execute it.
75.ICD pdftocairo
76will process the input PDF file and generate a new PDF file with the adjusted page dimensions.
77
78.LI "Inspect the Output (important!):"
79Once 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
80.ICD zathura ,
81to confirm that the page dimensions have been changed to A3 without affecting the content.