A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu




pdfcpu nup [-p(ages) selectedPages] -- [description] outFile n inFile|imageFiles...


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 default
description configuration string no  
outFile PDF output file yes  
n the N-up value yes  
inFile PDF input file inFile or imageFile(s)  
imageFile… one or more images inFile or imageFile(s)  

N-up Value

The following table lists all supported values for n and the resulting grid layout with respect to the orientation of the chosen output paper size. See here for a thorough explanation of N-up.

value portrait landscape
2 1x2 2x1
3 1x3 3x1
4 2x2 2x2
8 2x4 4x2
9 3x3 3x3
12 3x4 4x3
16 4x4 4x4


A configuration string to specify the details of the n-up layout.

parameter values default
dimensions (width, height) in user units eg. ‘400 200’ 595 842
formsize, paper size paper size to be used. Append L or P to enforce landscape/portrait mode A4
orientation one of rd, dr, ld, dl for PDF input files rd
border on/off true/false on
margin float >= 0 0
backgroundcolor, bgcol color none


This is usually associated with the writing direction used in the document to be processed. For PDF input files only

value description
rd right down, default
dr down right
ld left down
dl down left

Default description

'formsize:A4, dimensions:595 842, orientation:rd, border:on, margin:3'


Create out.pdf by applying 4-up to in.pdf. Each page fits 4 original pages of in.pdf into a 2x2 grid:

$ pdfcpu nup out.pdf 4 in.pdf

The output file will use the page size of the input file unless explicitly declared by a description string like so:

$ pdfcpu nup -- "form:A4" out.pdf 9 in.pdf

nup also accepts a list of image files with the result of rendering all images in N-up fashion into a PDF file using the specified paper size (default=A4). Generate out.pdf using A4 Landscape mode where each page fits 4 images onto a 2x2 grid. The grid element border lines are rendered by default as well is the default margin of 3 points applied:

$ pdfcpu nup -- "form:A4L" out.pdf 4 *.jpg *.png *.tif

A single image input file supplied will produce a single page PDF ouput file.
In the following example logo.jpg will be 16-up’ed onto out.pdf. Both grid borders and margins are suppressed and the output format is Ledger:

$ pdfcpu nup -- "form:Ledger, bo:off, ma:0" out.pdf 16 logo.jpg