Cropping a PDF / Adding crop box using Ghostscript
I have a few hundred PDFs that I need to crop - I'm willing to either crop the actual documents or simply add a crop box to e开发者_JAVA百科ach so the correct viewable area shows when the PDF is opened.
How can I do this using Ghostscript (v8.71)? I found this:
gs -sDEVICE=pdfwrite -sOutputFile=marked.pdf [/CropBox [54 54 1314 810] /PAGES pdfmark original.pdf
I've tried this (and all variants I can think of) but I always get an error such as this:
Error: /undefinedfilename in ([/CropBox)
I've tried moving around the parameters of the command but nothing seems to work. Does anyone know how this can be accomplished?
Update: Still no crop box after correcting syntax, see results -
Results for: pdfinfo -box -f 1 -l 3 original.pdf
Producer: PDFlib 7.0.2 (PHP5/Linux)
CreationDate: Wed Oct 21 11:41:04 2009
ModDate: Wed Oct 21 13:38:22 2009
Tagged: no
Pages: 1
Encrypted: no
Page 1 size: 1423 x 918 pts
Page 1 MediaBox: 0.00 0.00 1423.00 918.00
Page 1 CropBox: 0.00 0.00 1423.00 918.00
Page 1 BleedBox: 54.00 54.00 1369.00 864.00
Page 1 TrimBox: 0.00 0.00 1423.00 918.00
Page 1 ArtBox: 0.00 0.00 1423.00 918.00
File size: 914373 bytes
Optimized: no
PDF version: 1.4`
Results for: pdfinfo -box -f 1 -l 3 marked.pdf
Producer: GPL Ghostscript 8.71
CreationDate: Wed Apr 27 15:43:38 2011
ModDate: Wed Apr 27 15:43:38 2011
Tagged: no
Pages: 1
Encrypted: no
Page 1 size: 1423 x 918 pts
Page 1 MediaBox: 0.00 0.00 1423.00 918.00
Page 1 CropBox: 0.00 0.00 1423.00 918.00
Page 1 BleedBox: 0.00 0.00 1423.00 918.00
Page 1 TrimBox: 0.00 0.00 1423.00 918.00
Page 1 ArtBox: 0.00 0.00 1423.00 918.00
File size: 392382 bytes
Optimized: no
PDF version: 1.4
Update: Example PDFs posted -
• able_to_crop.pdf
• cannot_crop.pdfYou are on the right track, trying to use pdfmark/Ghostscript for adding a CropBox. But your syntax isn't 100% correct.
Try this instead:
gs \
-sDEVICE=pdfwrite \
-o marked.pdf \
-c "[/CropBox [54 54 1314 810] /PAGES pdfmark" \
-f original.pdf
精彩评论