pdfcpu

Logo

A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Changelog

Grid

Usage

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

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


Arguments

name description required
description configuration string no
outFile PDF output file yes
m vertical span yes
n horizontal span yes
inFile PDF input file inFile or imageFile(s)
imageFile… one or more images inFile or imageFile(s)


Description

A configuration string to specify the details of the grid 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
enforce on/off true/false on
border on/off true/false on
margin float >= 0 0


Orientation

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

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


Enforce

true enforces best-fit orientation of individual content artifacts during rendering on grid.

false keeps original orientation of individual content artifacts during rendering on grid.


Default description

'form:A4, d:595 842, o:rd, bo:on, ma:3, enforce:on'


Examples

The page size of the output file is a grid of specified dimensions in original page units. Output pages may be big but that’s ok since they are not supposed to be printed.

One use case mentioned by the community was to produce PDF files for source code listings eg. in the form of 1x10 grid pages.
In the following example we use a 1x4 grid since this is easier to visualize.

Rearrange pages of in.pdf into pages composed of 1x4 grids and write the result to out.pdf using the default orientation. The output page size is the result of a 1(horizontal) x 4(vertical) grid using in.pdf’s page size:

$ pdfcpu grid -- "bo:off" out.pdf 4 1 in.pdf


When applied to image files this command produces simple photo galleries of arbitrary dimensions in PDF form.
Arrange imagefiles onto a 2x5 page grid and write the result to out.pdf using a grid cell size of 500x500:

$ pdfcpu grid -- "d:500 500, ma:20, bo:off" out.pdf 2 5 *.jpg


Rearrange pages of in.pdf into 2x2 grids and write result to out.pdf using the default orientation. The output page size is the result of a 2(hor)x2(vert) page grid using page size Legal in landscape mode:

$ pdfcpu grid -- "form:LegalL" out.pdf 2 2 in.pdf


Rearrange pages of in.pdf into 3x2 grids and write result to out.pdf using orientation ‘right down’. The output page size is the result of a 3(hor)x2(vert) page grid using in.pdf’s page size:

$ pdfcpu grid -- "o:rd" out.pdf 3 2 in.pdf