Chapter 9
Multipage Facilities

cpdf -pad-before in.pdf [<range>] [-pad-with pad.pdf] -o out.pdf

cpdf -pad-after in.pdf [<range>] [-pad-with pad.pdf] -o out.pdf

cpdf -pad-every [<integer>] in.pdf [-pad-with pad.pdf] -o out.pdf

cpdf -pad-multiple [<integer>] in.pdf -o out.pdf

cpdf -pad-multiple-before [<integer>] in.pdf -o out.pdf

cpdf [-impose <pagesize> | impose-xy <x y>]
     [-impose-columns] [-impose-rtl] [-impose-btt]
     [-impose-margin <margin>] [-impose-spacing <spacing>]
     [-impose-linewidth <width>] [-fast]
     in.pdf -o out.pdf

cpdf -twoup-stack [-fast] in.pdf -o out.pdf

cpdf -twoup [-fast] in.pdf -o out.pdf

9.1 Inserting Blank Pages

Sometimes, for instance to get a printing arrangement right, it’s useful to be able to insert blank pages into a PDF file. cpdf can add blank pages before a given page or pages, or after. The pages in question are specified by a range in the usual way:

cpdf -pad-before in.pdf 1 -o out.pdf

Add a blank page before page 1 (i.e. at the beginning of the document.)

cpdf -pad-after in.pdf 2,16,38,84,121,147 -o out.pdf

Add a blank page after pages 2, 16, 38, 84, 121 and 147 (for instance, to add a clean page between chapters of a document.)

The dimensions of the padded page are derived from the boxes (media box, crop box etc.) of the page after or before which the padding is to be applied.

The -pad-every n operation places a blank page after every n pages, excluding any last one. For example…

cpdf -pad-every 3 in.pdf -o out.pdf

Add a blank page after every three pages

…on a 9 page document adds a blank page after pages 3 and 6.

In all three of these operations, one may specify -pad-with providing a (usually one-page) PDF file to be used instead of a blank page. For example, a page saying “This page left intentionally blank”.

The -pad-multiple n operation adds blank pages so the document has a multiple of n pages. For example:

cpdf -pad-multiple 8 in.pdf -o out.pdf

Add blank pages to in.pdf so it has a multiple of 8 pages.

The -pad-multiple-before n operation adds the padding pages at the beginning of the file instead.

9.2 Imposition

Imposition is the act of putting two or more pages of an input document onto each page of the output document. There are two operations provided by cpdf:

cpdf -impose a0landscape in.pdf -o out.pdf

Impose as many pages as will fit on to new A0 landscape pages.

cpdf -impose-xy "3 4" in.pdf -o out.pdf

Impose 3 across and 4 down on to new pages of 3 times the width and 4 times the height of the input ones.

The x value for -impose-xy may be set to zero to indicate an infinitely-wide page; the y value to indicate an infinitely-long one.

In both cases, the pages in the input file are assumed to be of the same dimensions.

The following options may be used to modify the output:

To impose with rotated pages, for example to put two A4 portrait pages two-up on an A3 landscape page, rotate them prior to imposition.

Two other ways of putting multiple pages on a single page remain from earlier versions of cpdf which lacked a general imposition operation. The -twoup-stack operation puts two logical pages on each physical page, rotating them 90 degrees to do so. The new mediabox is thus larger. The -twoup operation does the same, but scales the new sides down so that the media box is unchanged.

cpdf -two-up in.pdf -o out.pdf

Impose a document two-up, keeping the existing page size.

cpdf -two-up-stack in.pdf -o out.pdf

Impose a document two-up on a larger page by rotation.

NB: For all imposition options, see also discussion of -fast in Section 1.13.

C Interface

 
/* CHAPTER 9. Multipage facilities */ 
 
/* cpdf_impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, 
 * linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing 
 * to fit a page of size x * y. This is controlled by fit. Columns imposes by 
 * columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is 
 * unused for now. Margin is the margin around the output, spacing the spacing 
 * between imposed inputs. */ 
void cpdf_impose(int, double, double, int, int, int, int, int, double, double, 
                 double); 
 
/* 
 * Impose a document two up. cpdf_twoUp does so by retaining the existing 
 * page size, scaling pages down. cpdf_twoUpStack does so by doubling the 
 * page size, to fit two pages on one. 
 */ 
void cpdf_twoUp(int); 
void cpdf_twoUpStack(int); 
 
/* 
 * cpdf_padBefore(pdf, range) adds a blank page before each page in the given 
 * range. 
 */ 
void cpdf_padBefore(int, int); 
 
/* 
 * cpdf_padAfter(pdf, range) adds a blank page after each page in the given 
 * range. 
 */ 
void cpdf_padAfter(int, int); 
 
/* cpdf_pageEvery(pdf, n) adds a blank page after every n pages. */ 
void cpdf_padEvery(int, int); 
 
/* 
 * cpdf_padMultiple(pdf, n) adds pages at the end to pad the file to a 
 * multiple of n pages in length. 
 */ 
void cpdf_padMultiple(int, int); 
 
/* 
 * cpdf_padMultiple(pdf, n) adds pages at the beginning to pad the file to a 
 * multiple of n pages in length. 
 */ 
void cpdf_padMultipleBefore(int, int);