Friday, June 26, 2009

Super-nifty perl script for cropping pdf files

I often need to include a PDF file in a LaTeX document. This works great if the PDF file has a reasonable bounding box, but most software exports PDFs as full-page.

I found a really great perl script that will crop a PDF by settings its bounding box to precisely enclose the PDF file's contents:

http://ctan.org/pkg/pdfcrop

I used it on a couple PDF tables produced by (gag) Microsoft Word 2007, and it worked great.

3 comments:

johnny_boy said...

If I weren't retarded I would install from source myself, but every time I've tried installing something from source it never works. Wish there were a .deb for this!

David Hovemeyer said...

It's just a single file - all I did was put it on my $PATH.

You do need to have ghostscript installed.

johnny_boy said...

Oh, it's just a script file? In that case...

I've also discovered pdfshuffler which does the same thing (and more!) in a graphical interface (except for the fact that you have to manually set the margin parameters, which may or may not involve some trial-and-error).

Cheers