1:√2 ≈ 1:1.414
ratio; US Letter (8.5″×11″) is ~1:1.294
. That means two different standards—and lots of mixed PDFs in the wild.
- Goal: confirm each PDF page’s ratio, then decide whether to accept it (e.g., A-series for print) or normalize it (e.g., to Letter for forms or KDP).
- Scope: We’re checking the page aspect ratio (not embedded images).
Which page box to measure (TrimBox → CropBox → MediaBox)
A PDF page can define up to five “page boxes”: MediaBox, CropBox, TrimBox, BleedBox, and ArtBox. For production-accurate aspect ratio, use this order:
- TrimBox — the final trimmed size (best for print deliverables).
- CropBox — the viewing area (fallback if TrimBox is missing).
- MediaBox — the full canvas (fallback if the others are missing).
Pro tip: Many viewers show CropBox by default. If you’re preparing for print, always prefer TrimBox when it exists.
Rotation & units (the two “silent” gotchas)
- Rotation: PDFs can declare a page rotation (0/90/180/270). If a page is rotated 90°, width and height may appear “swapped.” Always check the rotation value during your aspect ratio check.
- Units: PDF coordinates are in user units. By default,
1 unit = 1/72 inch
. Some PDFs change this via theUserUnit
entry. IfUserUnit ≠ 1
, multiply box dimensions by this value before computing aspect ratio.
Quick ways to check a PDF’s aspect ratio
Option 1 — Adobe Acrobat / Acrobat Reader (fastest GUI)
- Open the PDF → File > Properties to see Page Size.
- To keep it visible while browsing pages: Edit > Preferences > Page Display → enable Always Show Document Page Size. You’ll see page dimensions near the scroll bar.
Option 2 — Command line (Poppler pdfinfo
)
Print sizes for all pages (and every page box) reliably:
# Install poppler-utils (macOS: brew install poppler | Linux: apt/yum)
# List sizes for all pages:
pdfinfo -f 1 -l 9999 file.pdf
# Include all page boxes (Media/Crop/Bleed/Trim/Art) for each page:
pdfinfo -f 1 -l 9999 -box file.pdf
Compute the aspect ratio instantly with awk
:
pdfinfo -f 1 -l 9999 -box file.pdf |
awk '/^Page *[0-9]+ size:/ {
w=$4; h=$6; gsub(/[^0-9.]/,"",w); gsub(/[^0-9.]/,"",h);
r=w/h; printf("Page %s → ratio = %.6f (w/h)\n", $2, r)
}'
Option 3 — Python (programmable & cross-platform)
Use pypdf
to prefer TrimBox→CropBox→MediaBox, account for UserUnit
, and report rotation:
# pip install pypdf
from pypdf import PdfReader
import sys
def pick_box(page):
for name in ("trimbox", "cropbox", "mediabox"):
box = getattr(page, name, None)
if box:
return box, name
return page.mediabox, "mediabox"
pdf = PdfReader(sys.argv[1])
for i, page in enumerate(pdf.pages, start=1):
box, which = pick_box(page)
uu = getattr(page, "user_unit", 1) or 1
w = float(box.width) * uu
h = float(box.height) * uu
rot = getattr(page, "rotation", 0) or 0
ratio = w / h if h else 0
print(f"Page {i}: {w:.2f}×{h:.2f} pt | box={which} | rot={rot} | ratio w/h={ratio:.6f}")
Batch-checking many PDFs (CSV report)
# macOS/Linux: create report.csv with one line per page across all PDFs
echo "file,page,width_pt,height_pt,ratio_w_over_h" > report.csv
for f in *.pdf; do
pdfinfo -f 1 -l 9999 -box "$f" |
awk -v F="$f" '/^Page *[0-9]+ size:/ {
w=$4; h=$6; gsub(/[^0-9.]/,"",w); gsub(/[^0-9.]/,"",h);
r=w/h; printf("%s,%s,%s,%s,%.8f\n", F, $2, w, h, r)
}'
done >> report.csv
How to fix or normalize aspect ratio
Fix in Acrobat Pro (no code)
- Tools > Print Production > Preflight.
- Click Single Fixups (wrench icon) → expand Pages.
- Use Scale pages to specified size to set a target (A4, Letter, custom).
Fix with Ghostscript (fit to a new page size)
Force pages to A4 (595×842 pt), scaling/centering as needed:
gs -o out.pdf -sDEVICE=pdfwrite \
-dFIXEDMEDIA -dPDFFitPage -sPAPERSIZE=a4 \
-dCompatibilityLevel=1.7 in.pdf
Fix with pdfcpu (precise boxes & resizing)
# Set TrimBox on page 2 and mirror to BleedBox:
pdfcpu box add -pages 2 -- "trim:[10 10 500 800], bleed:trim" in.pdf out.pdf
# Resize all pages to A4:
pdfcpu resize -pages all -paper a4 in.pdf out.pdf
Special case: ultra-tall “scroll” PDFs
Split each page into tiles that better match standard ratios:
# Two vertical tiles per page:
mutool poster -y 2 in.pdf out.pdf
Common page sizes & aspect ratios (cheat sheet)
Format | Size | Aspect (W:H) | Normalized |
---|---|---|---|
A4 | 210 × 297 mm | 0.7071:1 | 1:1.4142 (≈1:√2) |
A3 | 297 × 420 mm | 0.7071:1 | 1:1.4142 |
US Letter | 8.5 × 11 in | 0.7727:1 | 1:1.2941 |
US Legal | 8.5 × 14 in | 0.6071:1 | 1:1.6471 |
Tabloid | 11 × 17 in | 0.6471:1 | 1:1.5455 |
FAQ
Does “Page Size” equal aspect ratio?
Yes. Aspect ratio is just width ÷ height. Check “Page Size” in Acrobat and divide.
Which box should I trust for print?
TrimBox (finished size). If it’s missing, fall back to CropBox, then MediaBox.
Why do my numbers look swapped?
The page likely has a rotation flag (e.g., 90°). Read rotation along with width × height.
My PDF shows odd values like 0.35278 mm per unit—why?
You’re seeing user units (default 1/72″ per unit). If a file sets UserUnit
≠ 1, multiply dimensions by that factor before computing the ratio.