Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to crop PDF using PDFCrop

📅 2014-Mar-10 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ crop, pdf, pdfcrop ⬩ 📚 Archive

PDFCrop is a simple Perl script that can be used to crop every page of a PDF file down to its minimal size. That is, it removes all the margins so that the page is reduced to the bounding box of the content. This tool is most commonly used to crop the PDF figures exported from other tools, so that they can be inserted in LaTeX documents.

PDFCrop ships along with the texlive-extra-utils package, so you may need to install it:

$ sudo apt-get install texlive-extra-utils

Using the tool is easy:

$ pdfcrop in.pdf out.pdf

I got this error when I ran it under the fish shell:

Failed to execute process '/usr/bin/pdfcrop'. Reason:
exec: Exec format error
The file '/usr/bin/pdfcrop' is marked as an executable but could not be run by the operating system.

It turns out that PDFCrop script file uses 3 lines of bash at the top. So, you will need to run under bash or a bash compatible shell.

Tried with: PDFCrop 1.2 and Ubuntu 12.04