wundervoll
wundervoll

Reputation: 372

Remove CropBox from PDF file using Ghostscript

Using the following command in Linux, I'm adding a CropBox to an A4 PDF file in order to remove an ugly border from it.

gs -sDEVICE=pdfwrite \
-o output.pdf \
 -c '[/CropBox [35.5 465.7 269 790] /PAGES pdfmark' \
 -f input.pdf

I then wish to increase its size back to the original. Is there a way to remove the CropBox using Ghostscript or at least increase its size?

Upvotes: 1

Views: 1557

Answers (2)

David van Driessche
David van Driessche

Reputation: 7046

You can 'cheat' of course. While the cleanest way would be to remove the CropBox, setting the crop box equal to the media box essentially has the effect of showing the complete page. So if you run a command that inserts a crop box with the exact same size as the media box, that will have the exact same result as removing it.

And doing so doesn't make it a 'bad' file in any way (remark that KenS's comment about loss of quality still remains valid of course).

Upvotes: 0

KenS
KenS

Reputation: 31199

Essentially the answer is no, there is no supplied method for doing that. You could create a BeginPage procedure and have it execute a /PAGE pdfmark to set a new CropBox.

Please note that when you execute pdfwrite with a PDF file as input you are creating a brand new PDF file, not modifying the existing one. Every time you transform a file like this there is the possibility of loss of quality.

Upvotes: 0

Related Questions