pdfcpu

Logo

A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Changelog

Crop


Usage

pdfcpu crop description inFile [outFile] [flags]

Flags

namedescriptionrequired
p(ages)selected pagesno

Common Flags


Arguments

namedescriptionrequired
descriptionbox configuration stringyes
inFilePDF input fileyes
outFilePDF output fileno

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 "pos:bl, off:1 1, dim:25% 25%" in.pdf cropped.pdf -u cm


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