Editing

How to Crop PDF Margins and Remove Headers and Footers

ยท9 min read

Cropping a PDF is usually about getting rid of something you did not put there. A scanned page arrives with a black border and half a desk visible around the edges. A forty page report carries a running header you do not want in the printed version. Both are crop jobs, and both work the same way underneath, which is worth understanding before you start typing numbers into a form.

What cropping actually changes

Every PDF page carries at least two rectangles. The MediaBox is the full physical page, the sheet of paper the document believes it is printed on. The CropBox is the region a viewer is supposed to display. Normally the two are identical. Cropping sets the CropBox to something smaller than the MediaBox, and from then on every viewer shows you the smaller rectangle.

This is closer to laying a mask over the page than to cutting paper. The page content is untouched. Nothing is re-rendered and nothing is re-compressed, so text stays selectable and images keep their original resolution. The only thing that changed is four coordinates telling readers where the visible area now starts and ends.

That design has a real advantage. Cropping is lossless and reversible, so setting the CropBox back to the MediaBox returns the full page with none of the generational quality loss you get from re-encoding. It also has a consequence most people do not expect.

Cropping hides content, it does not remove it

Because the cropped area is masked rather than deleted, everything outside the CropBox is still in the file. The text of a cropped header is still in the content stream. Select all and copy from a cropped PDF and you can pull out text that appears nowhere on screen. Search tools index it. Text extraction returns it. Convert the file to Word and it reappears.

This matters when you are cropping to get rid of something rather than to tidy a layout. Cropping away a letterhead, a client name in a footer, or a watermark running along the bottom of every page does not make that information private. It makes it invisible in a viewer, which is a different thing, and anyone who opens the file in a tool that reads the MediaBox instead will see all of it.

If the content genuinely has to go, flatten the page after cropping. Convert the cropped PDF to JPG and then back to PDF. That rebuilds each page as a picture of the visible area only, and the hidden text stops existing in the file. You give up selectable text and searchability across the whole document, so it is a deliberate trade rather than something to do by default.

Why cropping does not shrink the file

The same mechanism explains a question that arrives right after the first crop. The file is the same size as before, occasionally a few bytes larger. Nothing was thrown away, so there is nothing to save. A page cropped to a quarter of its area still carries every image and font it carried before, plus four extra numbers.

To reduce the size, compress the PDF after cropping, or flatten it to images as above, which discards the off-page content along with everything else.

Getting the margins right

CocoPDF crops by margin rather than by drawing a box. You say how much to take off each edge in millimetres, and it removes that much from the top, right, bottom, and left independently. An edge left at zero is not touched.

Measuring is the awkward part, because a PDF does not come with a ruler. The practical method is to work from the page size. A4 is 210mm wide and 297mm tall, US Letter is 216 by 279. Judge the unwanted strip as a fraction of the full width or height and convert: a header band taking up roughly a fifteenth of an A4 page is about 20mm. Crop, look at the result, adjust. Since the operation is lossless, a second pass costs nothing.

Removing headers and footers across a whole document

This is the most common reason to crop, and it is the case the margin approach handles best. A running header or footer sits at the same distance from the page edge on every page, because sitting in the same place is what makes it a running header. One bottom margin value therefore clears the footer from all of them at once.

CocoPDF applies the margins you set to every page in the document. There is no page range to configure and no per-page adjustment, which is the right behaviour for headers and footers and the wrong behaviour for a document where only a few pages need trimming. For that case, extract the pages that need cropping, crop them, and merge the document back together.

Two things are worth checking first. Page numbers usually live in the footer, so cropping the footer takes them with it; if you still want numbering, add page numbers after cropping rather than before, since numbers added first get cropped away with everything else. And confirm the header really is consistent. Documents assembled from several sources often are not, and a margin that clears the header on page one can eat a line of body text on page thirty.

When cropping is the wrong tool

  • The page is skewed rather than badly framed. A few degrees off true needs perspective correction, which is what the document scanner does. No amount of cropping straightens a crooked page.
  • The page is sideways. Rotate it first, because crop margins apply relative to the stored orientation, so cropping a rotated page trims the wrong edges.
  • You want whole pages gone rather than parts of pages. Remove pages does that directly and does reduce the file size.
  • You are cropping to conceal something, which the file will still contain.

To crop, upload the PDF to the Crop PDF tool, set the margin to remove from each edge in millimetres, and process. The cropped file downloads immediately, with text still selectable and image quality unchanged.

Try it yourself

Everything in this article is free to use on CocoPDF, with no account needed.

โœ‚๏ธ Crop PDF