A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Add Boxes

Have a look at some examples.


pdfcpu boxes add [-p(ages) selectedPages] -- description inFile [outFile]


name description required
p(ages) selected pages no

Common Flags

name description values
v(erbose) turn on logging  
vv verbose logging  
q(uiet) quiet mode  
u(nit) display unit po(ints),in(ches),cm,mm
c(onf) config dir $path, disable
upw user password  
opw owner password  


name description required
description box configuration string yes
inFile PDF input file yes
outFile PDF output file no


A string representation for a sequence of box definitions and assignments:

m(edia): {box}
 c(rop): {box}
  a(rt): {box} | m(edia) | c(rop) | b(leed) | t(rim)
b(leed): {box} | m(edia) | c(rop) | a(rt)   | t(rim)
 t(rim): {box} | m(edia) | c(rop) | a(rt)   | b(leed)


Given the following page with a sole media box represented by the rectangular region [0 0 400 600]:

Set a 200 x 200 Crop Box located in lower left corner of media box:

$ pdfcpu box add -- "crop:[0 0 200 200]" in.pdf cropped.pdf
adding cropBox for in.pdf
writing cropped.pdf...
pages: all

Using the crop command we can achieve the same:

$ pdfcpu crop -- "[0 0 200 200]" in.pdf cropped.pdf
cropping in.pdf
writing cropped.pdf...
pages: all

The following command sets an absolute Trim Box in user space and assigns it in turn to Bleed Box for page 2 only:

$ pdfcpu box add -pages 2 -- "trim:[10 10 50 50], bleed:trim" in.pdf out.pdf
adding trimBox, bleedBox for in.pdf
writing out.pdf...

Here we define a Crop Box for all pages in terms of a general margin of 1 inch within Media Box.

We also define a Bleed Box in terms of relative margins within Crop Box and assign it to Art Box and Trim Box:

$ pdfcpu box add -u inches -- "c:1, b:15%, a:b, t:b" in.pdf out.pdf
adding cropBox, trimBox, bleedBox, artBox for test.pdf
writing out.pdf...
pages: all

Learn more about box description