pdfcpu

Logo

A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Changelog

Crop


Usage

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


Flags

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  
-o(ffline) disable http traffic  
c(onf) config dir $path, disable
opw owner password  
upw user password  
u(nit) display unit po(ints),in(ches),cm,mm


Arguments

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


Examples

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


Crop a 200 x 200 points region located in lower left corner of media box:

$ pdfcpu crop -- "[0 0 200 200]" in.pdf cropped.pdf


Margins and offsets may be expressed in any display unit you like (po,cm,mm,in). Crop a region located in the bottom left corner of the media box with dimension expressed as relative width and height of the media box applying a horizontal/vertical offset of 1 cm:

$ pdfcpu crop -u cm -- "pos:bl, off:1 1, dim:25% 25%" in.pdf cropped.pdf


Crop relative to media box using 100 points for each of the four margins:

$ pdfcpu crop -- "100" in.pdf cropped.pdf


The following command would set display unit to mm in order to express top, left/right and bottom margins relative to the media box defining the rectangular regions that we want to use as crop box:

$ pdfcpu crop -u mm -- "15 10 15" in.pdf cropped.pdf


The following command uses negative margins for cropping and therefore expands the media box:

$ pdfcpu crop -- "-10" in.pdf cropped.pdf