user1555320
user1555320

Reputation: 495

Ghostscript: adding BleedBox

I have a pdf with such pdfInfo:

pdfinfo -f 1 -l 1 -box book.pdf 
Title:          Hibaby book
Author:         Hibaby.biz
Creator:        HIBABY
Producer:       TCPDF 5.9.193 (http://www.tcpdf.org)
CreationDate:   Tue Mar  5 17:25:23 2013
ModDate:        Tue Mar  5 17:25:23 2013
Tagged:         no
Form:           none
Pages:          21
Encrypted:      no
Page    1 size: 595.276 x 841.89 pts (A4)
Page    1 rot:  0
Page    1 MediaBox:     0.00     0.00   595.28   841.89
Page    1 CropBox:      0.00     0.00   595.28   841.89
Page    1 BleedBox:     0.00     0.00   595.28   841.89
Page    1 TrimBox:      0.00     0.00   595.28   841.89
Page    1 ArtBox:       0.00     0.00   595.28   841.89
File size:      3771955 bytes
Optimized:      no
PDF version:    1.7

following this thread I try to resize and add a bleeBox with this command:

gs -o output.pdf \
   -sDEVICE=pdfwrite \
   -r72 \
   -dPDFA \
   -sProcessColorModel=DeviceCMYK \
   -dFIXEDMEDIA \
   -dDEVICEWIDTHPOINTS=667 \
   -dDEVICEHEIGHTPOINTS=913 \
   -c "[/ArtBox[36 36 631 877]" \
   -f book.pdf

i only get a slightly bigger pdf with correct mediabox but no bleedbox attached... what Am I missing?

pdfinfo -f 1 -l 1 -box output.pdf 
Producer:       GPL Ghostscript 9.06
CreationDate:   Fri May 17 11:10:49 2013
ModDate:        Fri May 17 11:10:49 2013
Tagged:         no
Form:           none
Pages:          21
Encrypted:      no
Page    1 size: 595.276 x 841.89 pts (A4)
Page    1 rot:  0
Page    1 MediaBox:     0.00     0.00   667.00   913.00
Page    1 CropBox:      0.00     0.00   595.28   841.89
Page    1 BleedBox:     0.00     0.00   595.28   841.89
Page    1 TrimBox:      0.00     0.00   595.28   841.89
Page    1 ArtBox:       0.00     0.00   595.28   841.89
File size:      534004 bytes
Optimized:      no

I don't understand what is wrong: the command, the syntax or if I'm just trying to make something impossible thanks for any help!

PDF version: 1.4

Upvotes: 2

Views: 2584

Answers (2)

Nick DS
Nick DS

Reputation: 11

I recently had the need for this myself but the proposed solution using Ghostscript wasn't working for me. I created a small utility called pdfboxer to do this which uses Apache PDFBox underneath. You can download the source from https://github.com/nicknux/pdfboxer.

It allows you to change the TrimBox, ArtBox, BleedBox, and CropBox.

Sample usage for the utility is:

$ java -jar bin/pdfboxer-0.0.1.jar \ -trimBox 7.200000,7.200000,504.000031,720.000000 \ -artBox 7.200000,7.200000,504.000031,720.000000 \ -sourceFile src/test/pdfs/UNTRIMMED_PDF.pdf \ -destFile src/test/pdfs/TRIMMED_PDF.pdf

Upvotes: 0

KenS
KenS

Reputation: 31199

Firstly, nowhere in your command line do you specify a BleedBox. You do mention an ArtBox but that's not the same thing.

Secondly, you can't just arbitrarily stick a /ArtBox in the PostScript stream and expect it to do anything. This "[/ArtBox[36 36 631 877]" isn't even valid PostScript because you have unbalanced array marks.

Your command line should instead read

-c "[/ArtBox [36 36 631 877] /PAGES pdfmark" -f

Unless You actually do want a BleedBox in which case you will have to replace the /ArtBox with /BleedBox.

Upvotes: 3

Related Questions