EricB
EricB

Reputation: 478

How To Setup Postscript MediaBox, BleedBox, and TrimBox with Ghostscript

I'm trying to setup a book to print at Blurb.com. I'm preparing the PDF and want to setup the MediaBox, Bleedbox, and TrimBox to confirm that my document is setup correctly for printing. There is an existing question here about the BleedBox, but, the answers do not change the output as reported by pdfinfo and changing multiple boxes is not covered.

Test Script

#!/bin/sh
gs -o output.pdf \
   -sDEVICE=pdfwrite \
   -r72 \
   -dPDFX \
   -sProcessColorModel=DeviceCMYK \
   -dFIXEDMEDIA \
   -dDEVICEWIDTHPOINTS=660 \
   -dDEVICEHEIGHTPOINTS=910 \
    -c "[/BleedBox [36 36 600 877] /PAGES pdfmark" \
    -f test_in.pdf

pdfinfo -f 1 -l 1 -box output.pdf

Output

GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 17.
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
Producer:       GPL Ghostscript 9.50
CreationDate:   Sun Jan  5 15:46:42 2020
ModDate:        Sun Jan  5 15:46:42 2020
Tagged:         no
Form:           none
Pages:          17
Encrypted:      no
Page    1 size: 660 x 910 pts (rotated 0 degrees)
Page    1 MediaBox:     0.00     0.00   660.00   910.00
Page    1 CropBox:      0.00     0.00   660.00   910.00
Page    1 BleedBox:     0.00     0.00   660.00   910.00
Page    1 TrimBox:      0.00     0.00   660.00   910.00
Page    1 ArtBox:       0.00     0.00   660.00   910.00
File size:      1213265 bytes
Optimized:      no
PDF version:    1.3

Upvotes: 0

Views: 1680

Answers (1)

KenS
KenS

Reputation: 31199

Your input is a PDF file (rather than, say, a PostScript program), which means it already has a /MediaBox and possibly other boxes as well. Note that setting -dFIXEDMEDIA means that you really shouldn't try and change the MediaBox, I mention this because you reference the MediaBox in your question.

Your command line starts by setting up the BleedBox, and then runs the PDF file. The PDF file's own BleedBox (if present) therefore overwrite the BleedBox you set up using a pdfmark, because it comes after the initial setup.

If you execute the pdfmark after running the PDF file, then the pdfmark will override the PDF file, which is (I believe) what you want.

So to take your command line:

gs -o output.pdf \
   -sDEVICE=pdfwrite \
   -r72 \
   -dPDFX \
   -sProcessColorModel=DeviceCMYK \
   -dFIXEDMEDIA \
   -dDEVICEWIDTHPOINTS=660 \
   -dDEVICEHEIGHTPOINTS=910 \
    test_in.pdf \
    -c "[/BleedBox [36 36 600 877] /PAGES pdfmark" \
    -f

NOTE: You are requesting PDF/X-3 output, but you haven't set a PDF/X definition program, which means that the output will not be PDF/X-3 compliant because you have not specified a CMYK ICC profile. See here

To set multiple Box values, you just add them to the pdfmark. The pdfmark reference can be found here today, but be warned that Adobe rearrange the furniture on their web site frequently, it'll probably move. Googling for 'pdfmark technical reference' should find it.

Upvotes: 2

Related Questions