Thread: Cropping PDFs
View Single Post
Old 08-14-2006, 08:44 AM   #2
ali doesn't litterali doesn't litter
ali's Avatar
Posts: 302
Karma: 116
Join Date: May 2006
Device: Iliad, dude!
I found that all PDF's I tried so far could be cropped manually by editing the MediaBox.

For example, an A4 PDF will contain something like
/MediaBox [ 0 0 595 842 ]
in one or several places. I just adjusted the four values - to crop 50 points from each border, I'd change that to
/MediaBox [ 50 50 545 792 ]
Both acroread and xpdf will honor that. That way, you can even crop page numbers / chapter headings and such away.

Under Linux, I'd do it using sed:
sed 's/0 0 595 842/50 50 545 792/g' <book.pdf >cropped.pdf
Under Windows, you'd have to open the pdf in notepad or something (don't know if that harms binary streams in the pdf)
ali is offline   Reply With Quote