Home » Misc » Crop PDF …

Crop PDF files with Ghostscript

Normally, with the following command and justifications on the CropBox parameters, it should work.

 gs -o cropped.pdf -sDEVICE=pdfwrite -dFirstPage=150 -dLastPage=180 -c "[/CropBox [100 100 500 500]" -f in.pdf 

in case the pdf file has no CropBox property, which can be checked with

 pdfinfo in.pdf 

then the following command can be used instead

 gs -o cropped.pdf -sDEVICE=pdfwrite -dFirstPage=150 -dLastPage=180 -dDEVICEWIDTHPOINTS=200 -dDEVICEHEIGHTPOINTS=250 -dFIXEDMEDIA -c "<</PageOffset [-21 -32]>> setpagedevice" -f in.pdf