What cropping a PDF really does: CropBox, MediaBox and hidden margins

Why a cropped PDF keeps the trimmed content, what the CropBox and MediaBox are, how white margins are found, and why colours merge in black and white.

Open the PDF crop Free, in your browser, nothing uploaded.

Cropping a PDF feels like cutting paper, but inside the file nothing is cut at all. This article explains what a PDF page size really is, why trimmed margins can reappear, how automatic margin finding works, and what a black-and-white copy does to colours. It is for students reading scans on a phone and anyone printing slides. Before cropping, put the pages in order with organise PDF; afterwards, make the file smaller with file compressor; and if the margins hold something private, use redact PDF instead, because a crop only hides it.

What it is

A PDF page is not a sheet of pixels. It is a list of drawing instructions (text, lines, pictures) placed on a coordinate grid measured in points, where 72 points make one inch and about 2.83 points make one millimetre. An A4 page is 595.28 × 841.89 points.

Each page carries a few rectangles that say which part of that grid matters:

  • MediaBox: the size of the physical sheet the page was made for.
  • CropBox: the part a viewer should show and a printer should print. If it is missing, it is the same as the MediaBox.

Cropping means setting a smaller CropBox. The drawing instructions outside it stay in the file, untouched, which is why text stays sharp and searchable after a crop. It also means that anything in the trimmed margins can still be found by someone who opens the file in an editor or reads its text.

Some viewers and printers ignore the CropBox and show the MediaBox. Setting the MediaBox to the same smaller rectangle makes the crop show everywhere.

Finding the white margins works on a picture of the page. The page is drawn at up to 1,100 pixels on its long side, and every pixel is given a brightness from 0 (black) to 255 (white). Any pixel darker than 245 counts as content. The leftmost, rightmost, top and bottom content pixels mark the edges, and the gaps beyond them are the margins. When every page shares one set of margins, the smallest gap on each side across all pages is used, so no page loses content.

Black and white turns each colour into one grey with the weights 0.299 red, 0.587 green and 0.114 blue, because the eye sees green as brighter than red and red as brighter than blue.

How to use it

  1. Choose a PDF. The first page appears with a shade over the part that will be cut.
  2. Under Apply to, pick Every page (same margins) or Each page on its own, and pick millimetres or inches under Units.
  3. Type the Top, Right, Bottom and Left margins, or press Find white margins. Set Keep a border of so the text does not touch the edge.
  4. Step through the pages with Previous and Next and check nothing important is shaded.
  5. Leave the box for shrinking the page size ticked so every viewer shows the crop. Tick the black and white box only if you want a grayscale copy for printing.
  6. Press Download cropped PDF.

A worked example

A scanned A4 chapter (210 × 297 mm) has wide borders. Find white margins says the text starts 25 mm from the left and right edges, 28 mm from the top and 23 mm from the bottom. With Keep a border of 3 mm, the tool cuts 22 mm left, 22 mm right, 25 mm top and 20 mm bottom.

  • New width: 210 − 22 − 22 = 166 mm, which is 166 × 72 / 25.4 = 470.56 points.
  • New height: 297 − 25 − 20 = 252 mm, or 714.33 points.
  • New box in the file: starting 22 mm (62.36 points) from the left and 20 mm (56.69 points) up from the bottom, because PDF coordinates count upwards from the bottom-left corner.
  • On a phone that fits the page to its width, everything is 210 / 166 = 1.265 times as big: text 26.5% larger with no zooming.

If you also tick black and white, a red heading and a green chart line become greys of 76 and 75: almost the same.

Checked with the tools

A script (scripts/blog-figures/pdf-crop-guide.mjs) ran the example through the tool’s own cropBoxFor() and grayInPlace() from src/lib/docs/pdfcrop.ts. It returned a box at x 62.362, y 56.693, 470.556 × 714.331 points (166.0 × 252.0 mm), then repeated the crop for side margins of 0 to 60 mm and ran seven colours through the grayscale step.

Text size gain on a phone after trimming an A4 pageText size gain on a phone after trimming an A4 page0501000102030405060Margin cut from left and right (mm each)Text bigger by (%)22 mm: +26.5 %fibub.com
An A4 page (595.28 x 841.89 points) run through the tool's cropBoxFor() with the same cut on the left and right. The gain is the old width over the new width, minus one: how much bigger everything looks when the page is fitted to a screen.
The grey each colour turns intoThe grey each colour turns into050100150200255BlackBlueDark redGreenRedOrangeYellowColour on the pageGrey level (0 black, 255 white)fibub.com
Pure colours run through the tool's grayInPlace(), which uses the Rec. 601 weights 0.299 red, 0.587 green and 0.114 blue.

The second chart is the reason to check a grayscale copy before printing a whole report: red and green lines in a chart become one grey, and blue text comes out nearly black.

Where it is used

  • Reading on a phone or e-reader. Scans and lecture notes with wide borders become readable without pinching and zooming.
  • Printing slides. Cropping the white frame off exported slides lets more fit on each sheet.

Common mistakes

  • Using crop to hide private details. The content is still in the file. Redact it instead.
  • Automatic margins on a page with a stray mark. A page number, scanner shadow or punched hole counts as content and stops the crop short. Check each page, or switch to per-page margins.
  • Cutting with no border. Text that touches the edge looks cramped and can be clipped by printers. Keep 2 to 5 mm.
  • Grayscale for a file you will search. Black and white turns pages into pictures, so the text can no longer be selected. Keep your original.

Questions people ask

Can I undo a crop later? Yes, in a PDF editor that lets you reset the page boxes, because nothing outside the box was deleted. Keeping your original is simpler.

Why are the margins in points and not pixels? A PDF has no fixed pixel size; it can be shown at any zoom. Points are its built-in unit, the same at every size.

Sources

  • Crop sets the page's CropBox and MediaBox, the page-size entries defined in the PDF specification (ISO 32000), with pdf-lib (MIT). Page pictures use pdf.js (Apache 2.0). Grayscale uses the standard Rec. 601 weights (0.299 red, 0.587 green, 0.114 blue). All of it runs in your browser.

If you are an author or publisher and want a credit or a passage changed or removed, tell us and we will act quickly.

Tools in this article

Read next