Grid
Rearrange the pages of a PDF file into grid pages for enhanced reading experience.
Arrange image files into grid pages for enhanced browsing experience.
Have a look at some examples.
Usage
pdfcpu grid [-v(erbose)|vv] [-pages pageSelection] [description] outFile m n inFile|imageFiles...
Flags
flag | description | required |
---|---|---|
verbose | turn on logging | no |
vv | verbose logging | no |
pages | page selection | no |
Arguments
name | description | required |
---|---|---|
description | configuration string | no |
outFile | PDF output file | yes |
m | horizontal span | yes |
n | vertical 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 | description | values | default |
---|---|---|---|
d | dimensions | (width, height) in user units eg. ‘400 200’ | d: 595 842 |
f | form/paper size | paper size to be used. Append L or P to enforce landscape/portrait mode | f: A4 |
o | orientation | one of rd, dr, ld, dl for PDF input files | o: rd |
b | element border | on/off true/false | b: on |
m | element margin | integer >= 0 | m: 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 |
Default description
'f:A4, d:595 842, o:rd, b:on, m:3'
You only have to specify any parameter diverging from the default.
Only one of dimensions or format is allowed.
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 'b:off' out.pdf 1 4 in.pdf
When applied to image files this command produces simple photo galleries of arbitrary dimensions in PDF form.Arrange imagefiles onto a 5x2 page grid and write the result to out.pdf using a grid cell size of 500x500:
pdfcpu grid 'd:500 500, m:20, b:off' out.pdf 5 2 *.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 '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