A PDF page carries up to four boxes: the media box for the full sheet, the crop box for the visible area, the trim box for the finished size, and the bleed box for artwork that runs off the edge. If the trim or bleed box is wrong, the printer cuts the page in the wrong place.
What you need
- Python with pikepdf installed
- A PDF destined for print
- The printer’s required trim size and bleed amount
- A terminal
Step 1: Open the PDF and read the boxes
Open the file with pikepdf and print each page’s mediabox, cropbox, trimbox, and bleedbox values, which are given in points.
Step 2: Compare the trim and bleed boxes with the job specification
Check that the trim box equals the finished page size and that the bleed box extends beyond the trim box by the bleed amount the printer asked for.
Step 3: Fix the boxes in the source application if they are wrong
Do not edit the boxes by hand in the PDF; correct the page setup in the application that created the file and re-export, then re-run the check.
Worked example: synthetic page-box check on an A4 brochure
The table below is a synthetic example. It shows the expected result of the box comparison; no check was run.
| Box | Value in points | Expected |
|---|---|---|
| MediaBox | 0, 0, 595, 842 | A4 sheet |
| TrimBox | 0, 0, 595, 842 | A4 finished size |
| BleedBox | -3, -3, 598, 845 | Only about 1 mm bleed |
| Verdict | Bleed too small | Re-export with 3 mm bleed |
Expected result (UNTESTED). the media and trim boxes match A4, but the bleed box extends only about 1 mm beyond the trim box instead of the required 3 mm, so the file must be re-exported with proper bleed. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- pikepdf reads the boxes as stored; a box that is missing falls back to the media box, which can hide a mistake.
- Box values are in points, so convert millimetres to points before comparing.
- Cropping in a viewer changes only the crop box, not the underlying artwork.
