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

  1. pdfcpu grid [-v(erbose)|vv] [-pages pageSelection] [description] outFile m n inFile|imageFiles...

Flags

flagdescriptionrequired
verboseturn on loggingno
vvverbose loggingno
pagespage selectionno

Arguments

namedescriptionrequired
descriptionconfiguration stringno
outFilePDF output fileyes
mhorizontal spanyes
nvertical spanyes
inFilePDF input fileinFile or imageFile(s)
imageFile…one or more imagesinFile or imageFile(s)

Description

A configuration string to specify the details of the grid layout.

parameterdescriptionvaluesdefault
ddimensions(width, height) in user units eg. ‘400 200’d: 595 842
fform/paper sizepaper size to be used. Append L or P to enforce landscape/portrait modef: A4
oorientationone of rd, dr, ld, dl for PDF input fileso: rd
belement borderon/off true/falseb: on
melement margininteger >= 0m: 0

Orientation

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

valuedescription
rdright down, default
drdown right
ldleft down
dldown left

Default description

  1. '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:

  1. pdfcpu grid 'b:off' out.pdf 1 4 in.pdf

Grid  - 图1

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:

  1. pdfcpu grid 'd:500 500, m:20, b:off' out.pdf 5 2 *.jpg

Grid  - 图2

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:

  1. 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:

  1. pdfcpu grid 'o:rd' out.pdf 3 2 in.pdf