26

How can I easily crop a PDF page in a given PDF file? I prefer using as little coding as possible, and guess border geometries as little as possible...

7 Answers 7

49

There are several options:

  1. Crop by point-and-click using a GUI front-end:
  2. Crop by using the command line:
    • pdfcrop command (provided by texlive-extra-utils), using the following arguments: pdfcrop --margins '-30 -30 -250 -150' --clip input.pdf output.pdf (-left -top -right -bottom format).
    • PDFCrop
    • convert -crop command (provided by imagemagick)
    • Ghostscript
  3. Crop by writing your own script:
6
  • 2
    As a note to the GUI tools: pdf-quench and krop need Python and are aimed for Linux, briss and PDF scissors need Java.
    – w5l
    Oct 13, 2019 at 10:24
  • 1
    The margin unit for pdfcrop is bp which is close (but not equal) to point. Some details here for conversion.
    – Lalylulelo
    Feb 19, 2020 at 14:28
  • 2
    pdfcrop is almost magic. It did exactly what I wanted. Jul 12, 2020 at 19:15
  • 2
    pdfcrop (from texlive-extra-utils) is the winner! Apr 5, 2021 at 18:38
  • pdfcrop: To crop multi-page pdfs with varying bounding boxes, I used pdfcrop --clip --bbox '<origin x> <origin y> <output width> <output height>' input.pdf output.pdf. The origin is defined w.r.t. the bottom left corner and the unit is bp = 1/72 in.
    – Thomas
    Jun 27 at 20:35
2

For precise point-and-click cropping, one option is to use LibreOffice Draw.

The instructions below assume you want to crop part of a single-page PDF:

  • Start with a blank document
  • Select the Insert > Image... menu
  • Navigate to the PDF you wish to crop
    • The contents of the PDF will show up as an image
  • Right-click on the PDF content in your document and select the "Crop" menu item.
  • Use the handles to resize the viewable area of the PDF to the section you want to remain after cropping
  • Click outside of the PDF to disable the crop handles
  • Click again on the PDF content to position it however you want by:
    • Dragging it around the page
    • Using the arrow keys to move it
    • Use the Draw positioning tools to align or center the PDF content.

When you're happy with the result, save, export it to PDF, or print it.

For multi-page PDFs, You'll have to work page by page by first splitting the PDF into multiple pages using some other tool like PDF Arranger (or simply "Printing to PDF" each page of the PDF you want to crop in your PDF viewer), cropping them one by one with Draw, then recombining them into a single PDF (using PDF Arranger again).

2

You can use Inkscape to losslessly crop PDFs. This uses Inkscape's built-in SVG-PDF conversion.

  1. Open your file in Inkscape: File -> Open -> select your file -> Open
  2. Resize PDF:
    • Using user-input values: File -> Document properties -> Page -> Custom size
    • Using auto resize to content: File -> Document properties -> Page -> Custom size -> Resize page to content... -> set desired margin -> Resize page to drawing or selection

Inkscape is a particularly good option as often PDF crop utilities (such as krop, mentioned in other answers) do not change the actual size of the object, instead adjusting how much of the object (e.g. an A4 page) is displayed.

E.g. from krop homepage:

Unfortunately, there is no simple way to eliminate unnecessary/invisible parts of a PDF file. krop only adjusts which parts of a PDF are displayed; the original content is still there in the file and will, for instance, show up when editing the file in inkscape

Editing directly in Inkscape does exactly what this says is impossible.

1

For quick, GUI-aided PDF cropping tasks, try pdfarranger (available in Debian repos, formerly known as PDF-Shuffler).

1

The list of tools provided by @sparkler was interesting, but did not help me very much.

Some of the tools provided, actually cropped my pages, but usually they involved some conversion to an image which made pdf files blurry and hard to read.

In the end I used podofocrop of PoDoFo tools which was able to retain all the graphics at full resolution and the text as real text.

It will crop all pages to the minimal size (i.e. without a border).

The command is: podofocrop input.pdf output.pdf

To install on MacOS use brew install podofo

0

You could try using the pdfCropMargins Python program (https://pypi.org/project/pdfCropMargins/) with the -pg option to select the particular page. The command-line program offers many options, and also has an optional GUI.

-2

depending on your situation, you might not even need to crop. for example, if you just want to remove some text from the edge, you can:

# uncompress:
qpdf --stream-data=uncompress a.pdf b.pdf
# edit PDF like a text file, then compress again:
qpdf b.pdf c.pdf

https://github.com/qpdf/qpdf/releases

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.