01 / Reproducible tutorial
Why two A4 PDF pages can have different visible dimensions
Inspect a three-page synthetic PDF and distinguish media size, clipping and rotation before opening an editor.
A file can mix A4 portrait, rotated A4 and cropped Letter pages without being corrupt. The useful question is what each page's boxes and rotation actually describe. This walkthrough uses blank, synthetic pages so no customer document is needed.
1. Create an isolated environment
Install Python 3.10 or newer. From the repository root, create a project environment and install the pinned runtime dependency.
python -m venv .venv
# Windows PowerShell
.venv/Scripts/python.exe -m pip install -r requirements.txt
.venv/Scripts/python.exe examples/generate_sample.py
.venv/Scripts/python.exe pdf_geometry.py examples/sample.pdf --output examples/outputOn macOS or Linux, replace .venv/Scripts/python.exe with .venv/bin/python. The generated sample PDF is also available for inspection, alongside its JSON report and readable report.
2. Compare what is visible
Page 1 has an A4 MediaBox. Page 2 has the same unrotated box but a 90-degree page rotation, so its displayed width and height exchange places. Page 3 uses a Letter MediaBox with a smaller CropBox. For CropBox coordinates [18,36,594,756], the width is 594−18=576 and height is 756−36=720 default units. At UserUnit 1 this is 203.2 × 254 mm.
3. Keep the inspection separate from an edit
The CLI writes reports without modifying the PDF. Use the page numbers and box values to decide whether an edit is needed; a mixed-size group is not itself an error. If you choose to edit, KomoPDF is the related product, but this report does not promise that the editor automatically repairs every unusual file.
The sample has blank pages and metadata, not meaningful page content. The tool cannot determine reading order, text editability, OCR quality, print bleed suitability or digital-signature validity.