New Tool Radar

AI PDF

How to Check for Page Size Mismatches in a Merged PDF Before Sharing It

List the page size of every page in a merged PDF with qpdf and flag any page whose size differs from the rest.

Schematic with three steps: List the size of every page; Flag pages whose size differs; Fix the mismatched pages before sharing.

Merging files from different sources often mixes page sizes: A4 next to Letter, or a landscape page among portrait pages. A reader will not notice until printing, when pages come out at different sizes, so the sizes should be checked right after merging.

What you need

  • qpdf installed
  • A PDF made by merging several files
  • The expected page size for the document
  • A terminal

Step 1: List the size of every page

Run qpdf –json file.pdf and read the mediabox of each page, which gives the page dimensions in points. Convert the points to millimetres or inches for comparison.

Step 2: Flag pages whose size differs

Compare each page’s size with the expected size and note every page that differs, including pages rotated to landscape.

Step 3: Fix the mismatched pages before sharing

Re-export the mismatched source pages at the right size and re-merge, or crop and resize the pages in Acrobat, then re-run the listing to confirm all pages match.

Worked example: synthetic page-size check on a merged 18-page file

The table below is a synthetic example. It shows the expected result of the size listing; no listing was run.

Pages Size Verdict
Pages 1-10 A4, 595 x 842 pt Correct
Pages 11-12 Letter, 612 x 792 pt Mismatch
Pages 13-18 A4, 595 x 842 pt Correct
Total 18 pages 2 pages to fix

Expected result (UNTESTED). most pages are A4, but pages 11 and 12 are US Letter and must be re-exported at A4 before the file is shared. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • The mediabox is the full page size; a page can have a different crop box that hides part of it.
  • A page that looks the same size on screen can still differ by a few points.
  • Rotating a page swaps its width and height, which can look like a size mismatch.

Sources

See all