A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu



Zoom in/out of selected pages either by magnification factor or corresponding margin.
Optionally when zooming out draw a border around content and/or fill unused page space with some background color.

Have a look at some examples.


pdfcpu zoom [-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 configuration string yes
inFile PDF input file yes
outFile PDF output file no

factor, hmargin, vmargin, border, bgcolor


A configuration string with input parameters for the zoom command.

parameter values
factor 0.0 < x < 1.0 or x > 1.0
hmargin x < 0 for zooming in, x > 0 for zooming out
vmargin x < 0 for zooming in, x > 0 for zooming out
border true/false, t/f
bgcolor color

Zoom in and out of page content by some factor.

Zooming out results in some horizontal and vertical margins implied by unused page content space. Usually these will not be equal.

Another way to look at zooming is eg. I’d like to zoom out a little in order to create some desired horizontal or vertical margin.


Given in.pdf:

Zoom in by factor.

$ pdfcpu zoom -- "factor: 2"  in.pdf out.pdf

Zoom out by factor.

$ pdfcpu zoom -- "factor: .5"  in.pdf out.pdf

Zoom out by horizontal margin of 10 points.

$ pdfcpu zoom -- "hmargin: -10" in.pdf out.pdf

Zoom out by vertical margin of 1 inch. Draw border around content and fill background light gray.

$ pdfcpu zoom -unit inch -- "vmargin: 1, border:true, bgcolor:lightgray" in.pdf out.pdf