This Python script uses the PyPDF2 library to crop PDF pages to A4 size. It allows you to specify an input PDF file and generates an output PDF file with all pages cropped to A4 dimensions.
Sometimes, PDF files may contain pages that are not in the standard A4 size (595.276 x 841.890 points). This script helps you standardize the page size by cropping all pages to A4 dimensions.
-
Ensure you have Python installed on your system.
-
Install the required PyPDF2 library by running the following command:
pip install PyPDF2
-
Download the
crop.py
file from this repository. -
In the script, specify the paths of your input PDF file and the desired output file.
input_path = "/path/to/input.pdf" output_path = "/path/to/output.pdf"
-
Run the script:
python crop.py
-
After the script execution, you will have a new PDF file at the specified output path, where all pages are cropped to A4 size.
-
This script uses the PyPDF2 library. For more information about PyPDF2 and its functionalities, refer to the official documentation: PyPDF2 Documentation.
-
For more details on the A4 paper size and its dimensions, you can refer to standard paper size references or online resources.
Feel free to explore and modify the script according to your specific requirements!