Automatically crop white margins from a PDF
Auto-cropping trims a PDF's white margins by detecting where the printed content actually starts and ends on each page. This tool renders every page in your browser, finds the bounding box of all pixels darker than a luminance threshold of 245, and sets the page's crop box to that box plus a padding you choose. As with any crop, the hidden margins still exist in the file — viewers just stop showing them — and nothing is uploaded.
How it works
A PDF page carries several nested rectangles. The media box defines the full physical page; the crop box defines the part a viewer actually displays. Cropping never edits page content — it only shrinks the crop box, so everything outside it is hidden rather than deleted. That is what makes cropping instant and lossless, and also why it is not a redaction technique: resetting the crop box brings the margins straight back.
What auto-crop adds over manual cropping is measurement. Each page is rendered to a canvas with pdf.js, and the tool walks the pixel grid computing luminance — the perceived brightness of each pixel on a 0–255 scale. Any pixel below 245 is treated as content; the near-white cutoff deliberately ignores paper tint and JPEG compression haze while catching even light gray text. The tool tracks the minimum and maximum x and y of all content pixels, which yields the tightest rectangle enclosing everything printed on that page. That rectangle is converted from render pixels back to PDF points, expanded by the padding you configure so text does not touch the edge, and written to the page's crop box with pdf-lib.
Because every page is measured independently, each page gets its own best-fit crop: a landscape table keeps its width, a sparse closing page shrinks dramatically. The same property explains the tool's main quirk — a single dark speckle near a corner, a page number, or a footer rule counts as content and stretches the bounding box out to include it. If you would rather trim the same fixed amount from every page, or cut past headers and footers deliberately, use the manual crop tool instead.
Worked example: an academic paper on an e-reader
A 90-page conference paper used A4 pages of 595 × 842 points with generous LaTeX margins; the actual text block measured about 455 × 680 points. With padding set to 10 points, auto-crop produced crop boxes of roughly 475 × 700 points per page — the exact figures varied by a few points from page to page, since pages with wide equations or footnotes measured slightly larger. On a 6-inch e-reader that fits the crop box to the screen, the text rendered about 25% larger than before without any zooming or panning. The file size stayed at 2.4 MB, unchanged to within a few hundred bytes, because the margins were hidden rather than removed.
Frequently asked questions
Does auto-cropping delete the margins permanently?
No. Cropping only sets the crop box, the rectangle viewers display, while the full page and anything in the margins stays in the file. Another tool can reset the crop box and reveal the hidden area again.
How does the tool know where the content is on each page?
It renders the page to an image and scans every pixel, treating anything with a luminance below 245 as content. The smallest rectangle enclosing all of those pixels, plus your chosen padding, becomes the new crop box.
Can every page get a different crop?
Yes, each page is measured and cropped independently, so a page with a wide table keeps more width than a text-only page. That per-page fit is the main advantage over trimming a fixed amount from all pages.
Why was a page cropped less tightly than I expected?
Anything darker than the threshold counts as content, including page numbers, headers, footnote rules and stray scanner speckles near the page edge. A single dust spot in a corner is enough to stretch the bounding box out to it.
Does auto-cropping make the PDF file smaller?
No, the file size stays roughly the same because no content is removed — only the visible rectangle changes. If you need a smaller file, run a compression tool afterwards.