Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print only the MediaBox of a PDF?

How do you print only the MediaBox of a PDF ?

I tried changing MediaBox into CropBox and TrimBox but it didn't help (the PDF has garbage outside the MediaBox I want to get rid off before printing).

The solution should preferably be automatizable and usable under GNU/Linux.

like image 223
Skippy le Grand Gourou Avatar asked Dec 21 '25 01:12

Skippy le Grand Gourou


1 Answers

The default value of the CropBox is usually the MediaBox of a document. Also, in the general case, the CropBox is a subset of the MediaBox. That will of course depend on the PDF file you are dealing with.

The MediaBox is by definition, the size of the page you are going to be displaying/printing.

The CropBox is the region of the page that will get cropped and displayed/printed. Basically, everything in the CropBox gets printed, and everything outside of it does not, unless you specify differently during the printing.

Here is a link to the PDF reference. On page 145, you can find details about what each box does. Also, there is a nice diagram of how the boxes on a page are set up on page 964. That should give you some more information on what might be going on in your particular case.

There might be something else going on here. During the actual printing process, you can chose a setting to print printer marks, and colors. This could be what you are seeing. Disabling that setting, should fix the issue.

I know this information sounds more general, but that's the most I can give you without seeing the actual document. You can leave a comment and let me know if this doesn't work, or point me to some more specific information, and I can adjust my answer.

like image 186
Vel Genov Avatar answered Dec 22 '25 17:12

Vel Genov