Coherent PDF Command Line Tools: User Manual
Coherent PDF Command Line Tools: User Manual
User Manual
Version 2.5 (January 2022)
Adobe, Acrobat, and Adobe PDF are registered trademarks of Adobe Systems Incorporated.
Windows, Powerpoint and Excel are registered trademarks of Microsoft Corporation.
Quickstart Examples
Just a few of the facilities provided by the Coherent PDF Command Line Tools. See each chapter
for more commands and full details.
Read in.pdf, select pages 1, 2, 3 and 6, and write those pages to out.pdf.
Select the even pages (2, 4, 6...) from in.pdf and write those pages to out.pdf.
Using AND to perform several operations in order, here merging two files together and adding a
copyright stamp to every page.
Read control.txt and use its contents as the command line arguments for cpdf.
iii
cpdf -split in.pdf -o Chunk%%%.pdf -chunk 10
Split in.pdf into ten-page chunks, writing them to Chunk001.pdf, Chunk002.pdf etc.
Split in.pdf on bookmark boundaries, writing each to a file whose name is the bookmark
label.
Chapter 3: Pages
Scale both the dimensions and contents of in.pdf by a factor of two in x and y directions.
Scale the pages in in.pdf to fit the US Letter page size, writing to out.pdf
Shift the contents of the page by 26 pts in the x direction, and 18 millimetres in the y direction,
writing to out.pdf
Rotate the contents of the pages in in.pdf by ninety degrees and write to out.pdf.
iv
Encrypt in.pdf using 128bit PDF encryption using the owner password fred and the user
password joe and writing the encrypted file to out.pdf
Chapter 5: Compression
Squeeze in.pdf, writing to out.pdf. Squeezing rearranges the structure of the PDF file to
save space.
Chapter 6: Bookmarks
Add bookmarks in the same form from a prepared file bookmarks.txt to in.pdf, writing to
out.pdf.
Chapter 7: Presentations
v
cpdf -presentation in.pdf 2-end -trans Split -duration 10
-o out.pdf
Use the Split style to build a presentation from the PDF in.pdf, each slide staying 10 seconds on
screen unless manually advanced. The first page, being a title does not move on automatically,
and has no transition effect.
Stamp the file watermark.pdf on to each page of in.pdf, writing the result to out.pdf.
Add a page number and date to all the pages in in.pdf using the Courier font, writing to
out.pdf.
Add extra blank pages after pages one, three and four of a document.
vi
cpdf -copy-annotations from.pdf in.pdf -o out.pdf
Set the document in.pdf to open with the PDF Viewer’s toolbar hidden, writing to out.pdf.
Set the metadata in a PDF in.pdf to the contents of the file metadata.xml, and write the
output to out.pdf.
Set the document in.pdf to open in PDF Viewer showing two columns of pages, starting on
the right, putting the result in out.pdf.
Set the document in.pdf to open in PDF Viewer in full screen mode, putting the result in
out.pdf.
vii
cpdf -remove-files in.pdf -o out.pdf
Extract images from in.pdf to directory output (with the help of imagemagick).
List the fonts in use, and what pages they are used on.
Write the PDF in JSON format to the given file, parsing its content streams into individual JSON
objects too.
viii
Chapter 16: Optional Content Groups
Coalesce optional content groups after merging or stamping two files with OCGs with like
names.
Make sure all lines in in.pdf are at least 2 pts wide, writing to out.pdf.
Contents
1 Basic Usage 1
1.1 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Input and Output Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Input Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Working with Encrypted Documents . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Standard Input and Standard Output . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Doing Several Things at Once with AND . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.8 Setting the Producer and Creator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.9 PDF Version Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.10 File IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.11 Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.12 Object Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.13 Malformed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.14 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.15 Control Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.16 String Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.17 Text Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.18 Font Embedding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Pages 15
3.1 Page Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 Scale Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3 Shift Page Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 Rotating Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 Flipping Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6 Boxes and Cropping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.7 Showing Boxes and Printer’s Marks . . . . . . . . . . . . . . . . . . . . . . . . . . 20
xi
4 Encryption and Decryption 21
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Encrypting a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3 Decrypting a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 Compression 23
5.1 Decompressing a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Compressing a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 Squeezing a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 Bookmarks 25
6.1 List Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.1.1 Destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.2 Remove Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.3 Add Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.4 Opening bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.5 Making a Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7 Presentations 31
9 Multipage Facilities 41
9.1 Inserting Blank Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
9.2 Imposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10 Annotations 45
10.1 Listing Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.2 Copying Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.3 Removing Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
xii
11 Document Information and Metadata 47
11.1 Reading Document Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
11.2 Setting Document Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.3 XMP Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.4 Upon Opening a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.4.1 Page Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.4.2 Page Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
11.4.3 Display Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
11.5 Page Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
12 File Attachments 55
12.1 Adding Attachments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
12.2 Listing Attachments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
12.3 Removing Attachments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
12.4 Dumping Attachments to File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
14 Fonts 59
14.1 Listing Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
14.2 Listing characters in a font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
14.3 Copying Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
14.4 Removing Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
14.5 Missing Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
18 Miscellaneous 71
18.1 Draft Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
18.2 Blackening Text, Lines and Fills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
18.3 Hairline Removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
18.4 Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
18.5 Change PDF Version Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
18.6 Copy ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
18.7 Remove ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
18.8 List Spot Colours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
18.9 PDF Dictionary Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
xiii
18.10Removing Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
A Dates 77
A.1 PDF Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
A.2 XMP Metadata Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
xiv
Typographical Conventions
Command lines to be typed are shown in typewriter font in a box. For example:
When describing the general form of a command, rather than a particular example, square brack-
ets [] are used to enclose optional parts, and angled braces <> to enclose general descriptions
which may be substituted for particular instances. For example,
describes a command line which requires an operation and, optionally, a range. An exception is
that we use in.pdf and out.pdf instead of <input file> and <output file> to reduce
verbosity. Under Microsoft Windows, type cpdf.exe instead of cpdf.
xv
Chapter 1
Basic Usage
The Coherent PDF tools provide a wide range of facilities for modifying PDF files created
by other means. There is a single command-line program cpdf (cpdf.exe under Microsoft
Windows). The rest of this manual describes the options that may be given to this program.
1.1 Documentation
The operation -help / --help prints each operation and option together with a short de-
scription. The operation -version prints the cpdf version string.
1
2 Chapter 1. Basic Usage
and the simplest concrete example, assuming the existence of a file in.pdf is:
which copies in.pdf to out.pdf. The input and output may be the same file. Of course, we
should like to do more interesting things to the PDF file than that!
Files on the command line are distinguished from other input by their containing a period.
If an input file does not contain a period, it should be preceded by -i. For example:
cpdf -i in -o out.pdf
A whole directory of files may be added (where a command supports multiple files) by using
the -idir option:
The files in the directory myfiles are considered in alphabetical order. They must all be PDF
files. If the names of the files are numeric, leading zeroes will be required for the order to be
correct (e.g 001.pdf, 002.pdf etc).
To restrict cpdf to files ending in .pdf (in upper or lower or mixed case) add the option
-idir-only-pdfs before -idir:
extracts pages two, three, four and five from in.pdf, writing the result to out.pdf, assuming
that in.pdf contains at least five pages. Here are the rules for building input ranges:
• The words odd and even can be used in place of or at the end of a page range to restrict
to just the odd or even pages.
Chapter 1. Basic Usage 3
• The words portrait and landscape can be used in place of or at the end of a page
range to restrict to just those pages which are portrait or landscape. Note that the meaning
of “portrait” and “landscape” does not take account of any viewing rotation in place
(use -upright from chapter 3 first, if required). A page with equal width and height is
considered neither portrait nor landscape.
• The word reverse is the same as end-1.
• The word all is the same as 1-end.
• A range must contain no spaces.
• A tilde (˜) defines a page number counting from the end of the document rather than the
beginning. Page ˜1 is the last page, ˜2 the penultimate page etc.
• Prepending NOT to a whole page range inverts it.
• Prepending <n>DUP to a whole page range duplicates each page of the range <n> times.
For example:
To re-encrypt the file with its existing encryption upon writing, which is required if only the
user password was supplied, but allowed in any case, add the -recrypt option:
The password required (owner or user) depends upon the operation being performed. Separate
facilities are provided to decrypt and encrypt files (See Section 4).
When appropriate passwords are not available, the option -decrypt-force may be added
to the command line to process the file regardless.
extracts the last five pages of in.pdf in the correct order, writing them to out.pdf. It does
this by reversing the input, taking the first five pages and then reversing the result.
To supply passwords for a file from -stdin, use -stdin-owner <password> and/or
-stdin-user <password>.
Using -stdout on the final command in the pipeline to output the PDF to screen is not
recommended, since PDF files often contain compressed sections which are not screen-readable.
Several cpdf operations write to standard output by default (for example, listing fonts). A
useful feature of the command line (not specific to cpdf) is the ability to redirect this output to
a file. This is achieved with the > operator:
Use the -info operation (See Section 11.1), redirecting the output to file.txt.
Chapter 1. Basic Usage 5
Merge in.pdf and in2.pdf together, add text to both pages, append in3.pdf and write to
out.pdf.
1.7 Units
When measurements are given to cpdf, they are in points (1 point = 1/72 inch). They may
optionally be followed by some letters to change the measurement. The following are supported:
For example, one may write 14mm or 21.6in. In addition, the following letters stand, in some
operations (-scale-page, -scale-to-fit, -scale-contents, -shift, -mediabox,
-crop) for various page dimensions:
PW Page width
PH Page height
PMINX Page minimum x coordinate
PMINY Page minimum y coordinate
PMAXX Page maximum x coordinate
PMAXY Page maximum y coordinate
CW Crop box width
CH Crop box height
CMINX Crop box minimum x coordinate
CMINY Crop box minimum y coordinate
CMAXX Crop box maximum x coordinate
CMAXY Crop box maximum y coordinate
6 Chapter 1. Basic Usage
For example, we may write PMINX PMINY to stand for the coordinate of the lower left corner of
the page.
Simple arithmetic may be performed using the words add, sub, mul and div to stand for
addition, subtraction, multiplication and division. For example, one may write 14in sub 30pt
or PMINX mul 2
Merge in.pdf and in2.pdf, setting the producer to MyMerger and writing the output to out.pdf.
1.11 Linearization
Linearized PDF is a version of the PDF format in which the data is held in a special manner to
allow content to be fetched only when needed. This means viewing a multipage PDF over a
slow connection is more responsive. By default, cpdf does not linearize output files. To make it
Chapter 1. Basic Usage 7
do so, add the -l option to the command line, in addition to any other command being used.
For example:
This requires the existence of the external program cpdflin which is provided with commercial
versions of cpdf. This must be installed as described in the installation documentation provided
with your copy of cpdf. If you are unable to install cpdflin, you must use -cpdflin to let
cpdf know where to find it:
In extremis, you may place cpdflin and its resources in the current working directory, though
this is not recommended. For further help, refer to the installation instructions for your copy of
cpdf.
To keep the existing linearization status of a file (produce linearized output if the input is
linearized and the reverse), use -keep-l instead of -l.
To create new object streams if none exist, or augment the existing ones, use -create-objstm:
Write the file in.pdf to out.pdf, preserving any existing object streams, and creating any new ones
for new objects which have been added.
Write the file in.pdf to out.pdf with wholly new object streams.
8 Chapter 1. Basic Usage
Files written with object streams will be set to PDF 1.5 or higher, unless -keep-version is
used (see above).
If cpdf cannot reconstruct a malformed file, it is able to use the gs program to try to reconstruct
the PDF file, if you have it installed. For example, if gs is installed and in your path, we might
try:
The command line for -gs-malformed-force must be of precisely this form. Sometimes, on
the other hand, we might wish cpdf to fail immediately on any malformed file, rather than try
its own reconstruction process. The option -error-on-malformed achieves this.
Sometimes (old, pre-ISO standardisation) files can be technically well-formed but use ineffi-
cient PDF constructs. If you are sure the input files you are using are well formed, the -fast
option may be added to the command line (or, if using AND, to each section of the command line).
This will use certain shortcuts which speed up processing, but would fail on badly-produced
files. The -fast option may be used with:
Chapter 3
-rotate-contents -upright -vflip -hflip
-shift -scale-page -scale-to-fit -scale-contents
Chapter 1. Basic Usage 9
Chapter 8
-add-text -add-rectangle
-stamp-on -stamp-under -combine-pages
Chapter 9
-impose -impose-xy -twoup -twoup-stack
Some operating systems have a limit on the length of a command line. To circumvent this, or
simply for reasons of flexibility, a control file may be specified from which arguments are drawn.
This file does not support the full syntax of the command line. Commands are separated by
whitespace, quotation marks may be used if an argument contains a space, and the sequence \"
may be used to introduce a genuine quotation mark in such an argument.
Several -control arguments may be specified, and may be mixed in with conventional
command-line arguments. The commands in each control file are considered in the order in
which they are given, after all conventional arguments have been processed. It is recommended
to use -args in all new applications. However, -control will be supported for legacy
applications.
To avoid interference between -control and AND, a new mechanism has been added.
Using -args in place of -control will perform direct textual substitution of the file into the
command line, prior to any other processing.
A backslash is used to indicate that a character which would otherwise be treated specially
by the command line interpreter is to be treated literally. For example, Unix-like systems
attribute a special meaning to the exclamation mark, so the command line
It follows that backslashes intended to be taken literally must themselves be escaped (i.e. written
\\).
-info
-list-bookmarks
-set-author et al.
-list-annotations
-dump-attachments
-utf8
-stripped
-raw
Add -utf8 to use Unicode UTF8, -stripped to convert to 7 bit ASCII by dropping any high
characters, or -raw to perform no processing. The default unless specified in the documentation
for an individual operation is -stripped.
2.1 Merging
The -merge operation allow the merging of several files into one. Ranges can be used to
select only a subset of pages from each input file in the output. The output file consists of the
concatenation of all the input pages in the order specified on the command line. Actually, the
-merge can be omitted, since this is the default operation of cpdf.
Take page one of a.pdf and all but the first page of b.pdf, merge them and produce out.pdf.
cpdf -merge -idir files -o out.pdf
11
12 Chapter 2. Merging and Splitting
The -collate option collates pages: that is to say, it takes the first page from the first
document and its range, then the first page from the second document and its range and so on.
When all first pages have been taken, it begins on the second from each range, and so on.
The -retain-numbering option keeps the PDF page numbering labels of each document
intact, rather than renumbering the output pages from 1.
The -remove-duplicate-fonts option ensures that fonts used in more than one of the
inputs only appear once in the output.
The -merge-add-bookmarks option adds a top-level bookmark for each file, using the
filename. Any existing bookmarks are retained. The -merge-add-bookmarks-use-titles,
when used in conjunction with -merge-add-bookmarks, will use the title from each PDF’s
metadata instead of the filename.
2.2 Splitting
The -split operation splits a PDF file into a number of parts which are written to file, their
names being generated from a format. The optional -chunk option allows the number of pages
written to each output file to be set.
Split the even pages of a.pdf to the files out001.pdf, out002.pdf etc. with at most ten pages in
each file. The directory (folder) dir must exist.
If the output format does not provide enough numbers for the files generated, the result is
unspecified. The following format operators may be used:
%, %%, %%% etc. Sequence number padded to the number of percent signs
@F Original filename without extension
@N Sequence number without padding zeroes
@S Start page of this chunk
@E End page of this chunk
@B Bookmark name at this page
Numbers padded to a fixed width field by zeroes may be obtained for @S and @E by following
them with more @ signs e.g @E@@@ for a fixed width of three.
Now, there may be many bookmarks on a single page (for instance, if paragraphs are book-
marked or there are two subsections on one page). The splits calculated by -split-bookmarks
ensure that each page appears in only one of the output files. It is possible to use the @ operators
above, including operator @B which expands to the text of the bookmark:
Split a.pdf on bookmark boundaries, using the bookmark text as the filename.
The bookmark text used for a name is converted from unicode to 7 bit ASCII, and the following
characters are removed, in addition to any character with ASCII code less than 32:
Pages
cpdf -scale-page "<scale x> <scale y>" [-fast] in.pdf [<range>] -o out.pdf
cpdf -scale-to-fit "<x size> <y size>" [-fast]
[-scale-to-fit-scale <scale>]
in.pdf [<range>] -o out.pdf
cpdf -scale-contents [<scale>] [<position>] [-fast]
in.pdf [<range>] -o out.pdf
cpdf -shift "<shift x> <shift y>" [-fast] in.pdf [<range>] -o out.pdf
cpdf -rotate <angle> in.pdf [<range>] -o out.pdf
cpdf -rotateby <angle> in.pdf [<range>] -o out.pdf
cpdf -upright [-fast] in.pdf [<range>] -o out.pdf
cpdf -rotate-contents <angle> [-fast] in.pdf [<range>] -o out.pdf
cpdf -hflip [-fast] in.pdf [<range>] -o out.pdf
cpdf -vflip [-fast] in.pdf [<range>] -o out.pdf
cpdf -mediabox "<x> <y> <w> <h>" in.pdf [<range>] -o out.pdf
cpdf -cropbox "<x> <y> <w> <h>" in.pdf [<range>] -o out.pdf
cpdf -remove-cropbox in.pdf [<range>] -o out.pdf
(Also bleed, art, and trim versions of these two commands, for example -artbox,
-remove-trimbox)
cpdf -frombox <boxname> -tobox <boxname> [-mediabox-if-missing]
in.pdf [<range>] -o out.pdf
cpdf -hard-box <boxname> [-fast] in.pdf [<range>]
[-mediabox-if-missing] -o out.pdf
cpdf -show-boxes [-fast] in.pdf [<range>] -o out.pdf
cpdf -trim-marks [-fast] in.pdf [<range>] -o out.pdf
15
16 Chapter 3. Pages
usletterportrait usletterlandscape
uslegalportrait uslegallandscape
The -scale-to-fit operation scales each page in the range to fit a given page size, preserving
aspect ratio and centering the result.
The scale can optionally be set to a percentage of the available area, instead of filling it.
Scale a file’s pages to fit A4 portrait, scaling the page 90% of its possible size.
NB: -scale-to-fit operates with respect to the media box not the crop box. If necessary, set
the media box to be equal to the crop box first. In addition, -scale-to-fit presently requires
Chapter 3. Pages 17
that the origin of the media box be (0, 0). This can be assured by preprocessing with -upright
(described elsewhere in this chapter).
The -scale-contents operation scales the contents about the center of the crop box (or,
if absent, the media box), leaving the page dimensions (boxes) unchanged.
To scale about a point other than the center, one can use the positioning commands described in
Section 8.2.4. For example:
Scale a file’s contents on all pages to 50% of its original dimensions about a point 20pts from its top
right corner.
Shift pages to the right by 50 points (for instance, to increase the binding margin).
Set the rotation of all the pages in the input file to ninety degrees clockwise.
The -rotateby operation changes the viewing rotation of all the given pages by the relative
value given.
18 Chapter 3. Pages
Rotate all the pages in the input file by ninety degrees clockwise.
The -rotate-contents operation rotates the contents and dimensions of the page by the
given relative value.
Rotate all the page contents in the input file by ninety degrees clockwise. Does not change the page
dimensions.
The four numbers are minimum x, minimum y, width, height. x coordinates increase to the
right, y coordinates increase upwards. PDF file can also optionally contain a crop box for each
page, defining to what extent the page is cropped before being displayed or printed. A crop box
can be set, changed and removed, without affecting the underlying media box. To set or change
the crop box use -cropbox. To remove any existing crop box, use -remove-cropbox.
Remove cropping.
Note that the crop box is only obeyed in some viewers. Similar operations are available for the
bleed, art, and trim boxes (-art, -remove-bleed etc.)
This operation copies the contents of one box (Media box, Crop box, Trim box etc.) to another. If
-mediabox-if-missing is added, the media box will be substituted when the ’from’ box is
not set for a given page. For example
copies the Trim Box of each page to the Crop Box of each page. The possible boxes are
/MediaBox, /CropBox, /BleedBox, /TrimBox, /ArtBox.
A hard box (one which clips its contents by inserting a clipping rectangle) may be created
with the -hard-box operation:
This means the resultant file may be used as a stamp without contents outside the given box
reappearing. The -mediabox-if-missing option may also be used here.
20 Chapter 3. Pages
4.1 Introduction
PDF files can be encrypted using various types of encryption and attaching various permissions
describing what someone can do with a particular document (for instance, printing it or
extracting content). There are two types of person:
The User can do to the document what is allowed in the permissions.
The Owner can do anything, including altering the permissions or removing encryption
entirely.
There are five kinds of encryption:
• 40-bit encryption (method 40bit) in Acrobat 3 (PDF 1.1) and above
• 128-bit encryption (method 128bit) in Acrobat 5 (PDF 1.4) and above
• 128-bit AES encryption (method AES) in Acrobat 7 (PDF 1.6) and above
• 256-bit AES encryption (method AES256) in Acrobat 9 (PDF 1.7) – this is deprecated – do
not use for new documents
• 256-bit AES encryption (method AES256ISO) in PDF 2.0
21
22 Chapter 4. Encryption and Decryption
In addition, 128-bit encryption (Acrobat 5 and above) and AES encryption supports these:
-no-forms Cannot edit form fields
-no-extract Cannot extract text or graphics
-no-assemble Cannot merge files etc.
-no-hq-print Cannot print high-quality
Add these options to the command line to prevent each operation.
A blank user password is common. In this event, PDF viewers will typically not prompt for a
password for when opening the file or for operations allowable with the user password.
In addition, the usual method can be used to give the existing owner password, if the document
is already encrypted.
The optional -pw= preface may be given where a password might begin with a - and thus
be confused with a command line option.
When using AES encryption, the option is available to refrain from encrypting the metadata.
Add -no-encrypt-metadata to the command line.
Compression
cpdf provides basic facilities for decompressing and compressing PDF streams, and for repro-
cessing the whole file to ‘squeeze’ it.
If cpdf finds a compression type it can’t cope with, the stream is left compressed. When using
-decompress, object streams are not compressed. It may be easier for manual inspection to
also remove object streams, by adding the -no-preserve-objstm option to the command.
cpdf compresses any streams which have no compression using the FlateDecode method, with
the exception of Metadata streams, which are left uncompressed.
23
24 Chapter 5. Compression
Adding -squeeze to the command line when using another operation will squeeze the file or
files upon output.
The -squeeze operation writes some information about the squeezing process to standard
output. The squeezing process involves several processes which losslessly attempt to reduce
the file size. It is slow, so should not be used without thought.
The -squeeze-log-to <filename> option writes the log to the given file instead of to
standard output. Log contents is appended to the end of the log file, preserving existing
contents.
There are two options which turn off parts of the squeezer. They are -squeeze-no-recompress
for avoiding the reprocessing of malformed compressed sections, and -squeeze-no-page-data
for avoiding the reprocessing of malformed page data.
Chapter 6
Bookmarks
PDF bookmarks (properly called the document outline) represent a tree of references to parts of
the file, typically displayed at the side of the screen. The user can click on one to move to the
specified place. cpdf provides facilities to list, add, and remove bookmarks. The format used
by the list and add operations is the same, so you can feed the output of one into the other, for
instance to copy bookmarks.
25
26 Chapter 6. Bookmarks
If the page number is 0, it indicates that clicking on that entry doesn’t move to a page.
By default, cpdf converts unicode to ASCII text, dropping characters outside the ASCII
range. To prevent this, and return unicode UTF8 output, add the -utf8 option to the command.
To prevent any processing, use the -raw option. See Section 1.17 for more information. A
newline in a bookmark is represented as "\n".
By using -list-bookmarks-json instead, the bookmarks are formatted as a JSON array,
in order, of dictionaries formatted thus:
{ "level": 0,
"text": "1 Basic Usage",
"page": 17,
"open": false,
"target":
[ { "I": 17 },
{ "N": "/XYZ" },
{ "F": 85.039 },
{ "F": 609.307 },
null ]
}
See chapter 15 for more details of cpdf’s JSON formatting. Bookmark text in JSON book-
marks, however, is in UTF8 for ease of use.
6.1.1 Destinations
The destination is an extended description of where the bookmark should point to (i.e it can
be more detailed than just giving the page). For example, it may point to a section heading
halfway down a page. Here are the possibilities:
Chapter 6. Bookmarks 27
Format Description
[p /XYZ left top zoom] Display page number p with (left, top) positioned
at upper-left of window and magnification of zoom.
Writing “null” for any of left, top or zoom specifies no
change. A zoom of 0 is the same as “null”.
[p /Fit] Display page number p so as to fit fully within the
window.
[p /FitH top] Display page number p with vertical coordinate top
at the top of the window and the page magnified
so its width fits the window. A null value for top
implies no change.
[p /FitV left] Display page number p with horizontal coordinate
left at the left of the window, and the page magnified
so its height fits the window. A null value for left
implies no change.
[p /FitR left bottom right top] Display page number p magnified so as to fit entirely
within the rectangle specified by the other parame-
ters.
[p /FitB] As for /Fit but with the page’s bounding box (see
below).
[p /FitBH top] As for /FitH but with the page’s bounding box (see
below).
[p /FitBV left] As for /FitV but with the page’s bounding box (see
below).
The bounding box is the intersection of the page’s crop box and the bounding box of the page
contents. Some other kinds of destination may be produced by -list-bookmarks. They will
be preserved by -add-bookmarks and may be edited as your risk.
adds the bookmarks to the input file, writing to out.pdf. An error will be given if the
bookmarks file is not in the correct form (in particular, the numbers in the first column which
specify the level must form a proper tree with no entry being more than one greater than the
last).
Bookmarks in JSON format (see above) may be added with -add-bookmarks-json:
Remember that strings in JSON bookmark files are in UTF8, rather than as native PDF
strings.
A level of 0 will close all bookmarks, level 1 will open just the top level, closing all others etc. To
open all of them, pick a sufficiently large level.
The page(s) added will have the same dimensions, media and crop boxes as the first page of
the original file. The default title is “Table of Contents”, though this may be changed:
An empty title removes the title. The sequence \n may be used to split the title into lines.
The default font is 12pt Times Roman (and 24pt for the title). The base font and size may be
changed with -font and -font-size (see chapter 8 for full details):
By default, an entry for the new table of contents will be added to the document’s bookmarks.
To suppress this behaviour, add -toc-no-bookmark:
Presentations
The PDF file format, starting at Version 1.1, provides for simple slide-show presentations in
the manner of Microsoft Powerpoint. These can be played in Acrobat and possibly other PDF
viewers, typically started by entering full-screen mode. The -presentation operation allows
such a presentation to be built from any PDF file.
The -trans option chooses the transition style. When a page range is used, it is the
transition from each page named which is altered. The following transition styles are available:
Split Two lines sweep across the screen, revealing the new page. By default the lines are
horizontal. Vertical lines are selected by using the -vertical option.
Blinds Multiple lines sweep across the screen, revealing the new page. By default the lines are
horizontal. Vertical lines are selected by using the -vertical option.
Box A rectangular box sweeps inward from the edges of the page. Use -outward to make it
sweep from the center to the edges.
Wipe A single line sweeps across the screen from one edge to the other in a direction specified
by the -direction option.
Dissolve The old page dissolves gradually to reveal the new one.
Glitter The same as Dissolve but the effect sweeps across the page in the direction specified by
the -direction option.
31
32 Chapter 7. Presentations
To remove a transition style currently applied to the selected pages, omit the -trans option.
The -effect-duration option specifies the length of time in seconds for the transition
itself. The default value is one second.
The -duration option specifies the maximum time in seconds that the page is displayed
before the presentation automatically advances. The default, in the absence of the -duration
option, is for no automatic advancement.
The -direction option (for Wipe and Glitter styles only) specifies the direction of the
effect. The following values are valid:
0 Left to right
90 Bottom to top (Wipe only)
The Split style, with vertical lines, and each slide staying ten seconds unless manually advanced.
The first page (being a title) does not move on automatically, and has no transition effect.
To use different options on different page ranges, run cpdf multiple times on the file using a
different page range each time.
Chapter 8
33
34 Chapter 8. Watermarks and Stamps
stamps the file logo.pdf onto the odd pages of in.pdf, writing to out.pdf. A watermark
should go underneath each page:
The position commands in Section 8.2.4 can be used to locate the stamp more precisely (they are
calculated relative to the crop box of the stamp). Or, preprocess the stamp with -shift first.
The -scale-stamp-to-fit option can be added to scale the stamp to fit the page before
applying it. The use of positioning commands together with -scale-stamp-to-fit is not
recommended.
The -combine-pages operation takes two PDF files and stamps each page of one over
each page of the other. The length of the output is the same as the length of the “under” file.
For instance:
Page attributes (such as the display rotation) are taken from the “under” file. For best results,
remove any rotation differences in the two files using -upright (see above) first.
The -relative-to-cropbox option takes the positioning command to be relative to the crop
box of each page rather than the media box.
The default is black 12pt Times New Roman text in the top left of each page. The text can be
placed underneath rather than over the page by adding the -underneath option.
Text previously added by cpdf may be removed by the -remove-text operation.
To specify that bates numbering begins at the first page of the range, use -bates-at-range
instead. This option must be specified after the range is specified. To pad the bates number
36 Chapter 8. Watermarks and Stamps
8.2.4 Position
The position of the text may be specified either in absolute terms:
No attempt is made to take account of the page rotation when interpreting the position, so
-prerotate may be added to the command line if the file contains pages with a non-zero
viewing rotation (to silence the rotation warning, add -no-warn-rotate instead) This is
equivalent to pre-processing the document with -upright (see chapter 3).
The -relative-to-cropbox modifier can be added to the command line to make these
measurements relative to the crop box instead of the media box.
The default position is equivalent to -topleft 100.
The -midline option may be added to specify that the positioning commands above are
to be considered relative to the midline of the text, rather than its baseline. Similarly, the
-topline option may be used to specify that the position is taken relative to the top of the text.
Times-Roman
Times-Bold
Times-Italic
Times-BoldItalic
Helvetica
Helvetica-Bold
Helvetica-Oblique
Helvetica-BoldOblique
Courier
Courier-Bold
Courier-Oblique
Courier-BoldOblique
Symbol
ZapfDingbats
For example, page numbers in Times Italic can be achieved by:
See Section 14.3 for how to use other fonts. The font size can be altered with the -font-size
option, which specifies the size in points:
8.2.6 Colors
The -color option takes an RGB (3 values), CYMK (4 values), or Grey (1 value) color. Compo-
nents range between 0 and 1. The following RGB colors are predefined:
Color R, G, B
white 1, 1, 1
black 0, 0, 0
red 1, 0, 0
green 0, 1, 0
blue 0, 0, 1
Partly-transparent text may be specified using the -opacity option. Wholly opaque is 1 and
wholly transparent is 0. For example:
38 Chapter 8. Watermarks and Stamps
The -midline option may be used to make these vertical positions relative to the midline of a
line of text rather than the baseline, as usual.
The -line-spacing option can be used to increase or decrease the line spacing, where a
spacing of 1 is the standard.
This can be used to blank out or highlight part of the document. The following positioning
options work as you would expect: -topleft, -top, -topright, -right, -bottomright,
-bottom, -bottomleft, -left, -center. When using the option -pos-left "x y", the
point (x, y) refers to the bottom-left of the rectangle. When using the option -pos-right
"x y", the point (x, y) refers to the bottom-right of the rectangle. When using the option
-pos-center "x y", the point (x, y) refers to the center of the rectangle. The options
-diagonal and -reverse-diagonal have no meaning.
The -fast option may be added (see Chapter 1). The -stamp-as-xobject operation puts a
file in another as a Form XObject on the given pages. You can then use -prepend-content or
-postpend-content to use it.
cpdf -stamp-as-xobject stamp.pdf in.pdf [<range>] -o out.pdf
Chapter 9
Multipage Facilities
Add a blank page before page 1 (i.e. at the beginning of the document.)
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.)
41
42 Chapter 9. Multipage Facilities
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. . .
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:
• the -impose operation which, given a page size fits multiple pages into it; and
• the -impose-xy operation which, given an x and y value, builds an output page which
fits x input pages horizontally and y input pages vertically.
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:
Chapter 9. Multipage Facilities 43
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.
NB: For all imposition options, see also discussion of -fast in Section 1.13.
44 Chapter 9. Multipage Facilities
Chapter 10
Annotations
This produces an array of (page number, annotation) pairs giving the PDF structure of each
annotation. Destination pages for page links will have page numbers in place of internal PDF
page links, and certain indirect objects are made direct but the content is otherwise unaltered.
Here is an example entry for an annotation on page 10:
[
10,
45
46 Chapter 10. Annotations
A future version of cpdf will allow these JSON annotations to be edited and re-loaded into
a PDF file.
Copy annotations from the first ten pages of from.pdf onto the PDF file to.pdf, writing the result
to results.pdf.
47
48 Chapter 11. Document Information and Metadata
The details of the format for creation and modification dates can be found in Appendix A.
By default, cpdf strips to ASCII, discarding character codes in excess of 127. In order to
preserve the original unicode, add the -utf8 option. To disable all postprocessing of the string,
add -raw. See Section 1.17 for more information.
The -page-info operation prints the page label, media box and other boxes page-by-page
to standard output, for all pages in the current range.
TrimBox:
ArtBox:
Rotation: 0
Note that the format for boxes is minimum x, minimum y, maximum x, maximum y.
(The details of the format for creation and modification dates can be found in Appendix A.
Using the date "now" uses the time and date at which the command is executed. Note also that
-producer and -creator may be used to set the producer and/or the creator when writing
any file, separate from the operations described in this chapter.)
For example, to set the title, the full command line would be
The text string is considered to be in UTF8 format, unless the -raw option is added—in which
case, it is unprocessed, save for the replacement of any octal escape sequence such as \017,
which is replaced by a character of its value (here, 15).
50 Chapter 11. Document Information and Metadata
To set also any field in the XMP metadata, add -also-set-xmp. The field must exist
already. To set only the field (not the document information dictionary), add -just-set-xmp
instead.
To create XMP metadata from scratch, using any information in the Document Information
Dictionary (old-style metadata):
The date format is defined in Appendix A.2. Using the date "now" uses the time and date at
which the command is executed.
For instance:
NB: If the file has a valid /OpenAction setting, which tells the PDF reader to open at a certain
page or position on a page, this will override the page layout option. To prevent this, use the
-remove-dict-entry functionality from Section 18.9:
The page mode in a PDF file defines how a viewer should display the document when first
opened. The possible (case-sensitive) values are:
For instance:
For instance:
To have that page scaled to fit the window in the viewer, use -open-at-page-fit instead:
(Here, we used end to open at the last page. Any page specification describing a single page is
ok here.)
DecimalArabic 1, 2, 3, 4, 5. . .
LowercaseRoman i, ii, iii, iv, v. . .
UppercaseRoman I, II, III, IV, V. . .
LowercaseLetters a, b, c, . . . , z, aa, bb. . .
UppercaseLetters A, B, C, . . . , Z, AA, BB. . .
NoLabelPrefixOnly No number, but a prefix will be used if defined.
We can use -label-prefix to add a textual prefix to each label. Consider a file with twenty
pages and no current page labels (a PDF reader will assume 1,2,3. . . if there are none). We will
add the following page labels:
Chapter 11. Document Information and Metadata 53
i, ii, iii, iv, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, A-0, A-1, A-2, A-3, A-4, A-5
By default the labels begin at page number 1 for each range. To override this, we can use
-label-startval (we used 0 in the final command), where we want the numbers to begin
at zero rather than one. The option -labels-progress can be added to make sure the
start value progresses between sub-ranges when the page range specified is disjoint, e.g 1-9,
30-40 or odd.
Page labels may be removed altogether by using -remove-page-labels command. To
print the page labels from an existing file, use -print-page-labels. For example:
File Attachments
PDF supports adding attachments (files of any kind, including other PDFs) to an existing file.
The cpdf tool supports adding and removing document-level attachments — that is, ones which
are associated with the document as a whole rather than with an individual page, and also
page-level attachments, associated with a particular page.
attaches the Excel spreadsheet sheet.xls to the input file. If the file already has attachments,
the new file is added to their number. You can specify multiple files to be attached by using
-attach-file multiple times. They will be attached in the given order.
The -to-page option can be used to specify that the files will be attached to the given page,
rather than at the document level. The -to-page option may be specified at most once.
55
56 Chapter 12. File Attachments
Unless the -raw option is given, the filenames are stripped of dubious special characters before
writing. It is converted from unicode to 7 bit ASCII, and the following characters are removed,
in addition to any character with ASCII code less than 32:
The -im or -p2p option is used to give the path to the external tool, one of which must
be installed. The output specifer, e.g -o output/%%% gives the number format for num-
bering the images. Output files are named serially from 0, and include the page number
too. For example, output files might be called output/000-p1.jpg, output/001-p1.png,
output/002-p3.jpg etc. Here is an example invocation:
The output directory must already exist. The -dedup option deduplicates images entirely; the
-dedup-perpage option only per page.
57
58 Chapter 13. Working with Images
The format is page number, image name, x pixels, y pixels, x resolution, y resolution. The resolutions
refer to the image’s effective resolution at point of use (taking account of scaling, rotation etc).
Fonts
59
60 Chapter 14. Fonts
The first column gives the page number, the second the internal unique font name, the third
the type of font (Type1, TrueType etc), the fourth the PDF font name, the fifth the PDF font
encoding.
We may then print the table, giving either the font’s name (e.g /F46) or basename (e.g
/XYPLPB+NimbusSanL-Bold):
The first column is the character code, the second the Unicode codepoint, the character itself
and its Unicode name, and the third the Adobe glyph name.
Text in this font can then be added by giving -font /GHLIGA+c128. Be aware that due to the
vagaries of PDF font handling concerning which characters are present in the source font, not all
characters may be available, or cpdf may not be able to work out the conversion from UTF8 to
the font’s own encoding. You may add -raw to the command line to avoid any conversion, but
the encoding (mapping from input codes to glyphs) may be non-obvious and require knowledge
of the PDF format to divine.
The format is
62 Chapter 14. Fonts
The operation -embed-missing-fonts will process the file with gs (which must be installed)
to embed missing fonts (where found):
In addition to reading and writing PDF files in the original Adobe format, cpdf can read
and write them in its own CPDFJSON format, for somewhat easier extraction of information,
modification of PDF files, and so on.
The resultant JSON file is an array of arrays containing an object number followed by an
object, one for each object in the file and two special ones:
• Object -1: CPDF’s own data with the PDF version number, CPDF JSON format number,
and flags used when writing (which may be required when reading):
63
64 Chapter 15. PDF and JSON
• PDF arrays, dictionaries, booleans, and strings are the same as in JSON.
• Strings are converted to JSON string format in a way which, when reversed, results in the
original string.
[
[
-1,
{ "/CPDFJSONformatversion": { "I": 2 },
"/CPDFJSONcontentparsed": false,
"/CPDFJSONstreamdataincluded": true,
"/CPDFJSONmajorpdfversion": { "I": 1 },
"/CPDFJSONminorpdfversion": { "I": 1 } }
],
[
0,
{ "/Size": { "I": 4 }, "/Root": 4,
"/ID" : [ <elided>, <elided>] } ],
[
1, { "/Type": { "N": "/Pages" }, "/Kids": [ 3 ], "/Count": { "I": 1 } }
],
[
2,
{"S": [{ "/Length": { "I": 49 } },
"1 0 0 1 50 770 cm BT/F0 36 Tf(Hello, World!)Tj ET"] }
],
[
3, { "/Type": { "N": "/Page" }, "/Parent": 1,
"/Resources": {
"/Font": {
"/F0": {
"/Type": { "N": "/Font" },
Chapter 15. PDF and JSON 65
2, {
"S": [
{}, [
[
{ "F": 1.0 }, { "F": 0.0 }, { "F": 0.0 }, { "F": 1.0 }, { "F": 50.0 }, {
"F": 770.0 }, "cm" ], [ "BT" ], [ "/F0", { "F": 36.0 }, "Tf" ], [
"Hello, World!", "Tj" ], [ "ET" ] ]
] } ], [
The option -output-json-no-stream-data simply elides the stream data instead, leading
to much smaller JSON files.
The option -output-json-decompress-streams keeps the streams intact, and decom-
presses them.
The option -output-json-clean-strings converts any UTF16BE strings with no high
bytes to PDFDocEncoding prior to output, so that editing them is easier.
In a PDF file, optional content groups are used to group graphical elements together, so they
may appear or not, depending on the preference of the user. They are similar in some ways to
layers in graphics illustration programs.
List the optional content groups in the PDF, one per line, to standard output. UTF8.
Coalesce optional content groups. For example, if we merge or stamp two files both with
an OCG called ”Layer 1”, we will have two different optional content groups. Running
-ocg-coalesce-on-name will merge the two into a single optional content group.
Ensure that every optional content group appears in the order list.
67
Chapter 17
The standard paper sizes are listed in Section 3.1, or you may specify the width and height
directly, as described in the same chapter.
The standard paper sizes are listed in Section 3.1, or you may specify the width and height
directly, as described in the same chapter. The standard fonts are listed in chapter 8. The default
font is TimesRoman and the default size is 12.
69
Chapter 18
Miscellaneous
71
72 Chapter 18. Miscellaneous
To remove a single image only, specify -draft-remove-only, giving the name of the im-
age obtained by a call to -image-resolution as described in Section 13.2 and giving the
appropriate page. For example:
Contrary to their names, all these operations can use another color, if specified with -color.
This does not alter any of the actual data in the file — just the supposed version number. For
PDF versions starting with 2 add ten to the number. For example, for PDF version 2.0, use
-set-version 10.
18.6 Copy ID
The -copy-id-from operation copies the ID from the given file to the input, writing to the
output.
If there is no ID in the source file, the existing ID is retained. You cannot use -recrypt with
-copy-id-from.
18.7 Remove ID
The -remove-id operation removes the ID from a document.
74 Chapter 18. Miscellaneous
List the spot colors, one per line in in.pdf, writing to stdout.
Remove the entry for /One in every dictionary in.pdf, writing to out.pdf.
Replace the entry for /One in every dictionary in.pdf if the key’s value is the given value, writing
to out.pdf.
Remove the entry for /One in every dictionary in.pdf, writing to out.pdf.
Remove the entry for /One in every dictionary in.pdf if the key’s value is the given value, writing
to out.pdf.
Dates
D:YYYYMMDDHHmmSSOHH'mm'
where:
• MM is the month;
• DD is the day (01-31);
• HH is the hour (00-23);
A contiguous prefix of the parts above can be used instead, for lower accuracy dates. For
example:
D:2014 (2014)
D:20140103 (3rd January 2014)
77
78 Appendix A. Dates
YYYY
YYYY-MM
YYYY-MM-DD
YYYY-MM-DDThh:mmTZD
YYYY-MM-DDThh:mm:ssTZD
where:
YYYY year
MM month (01 = Jan)
DD day of month (01 to 31)
hh hour (00 to 23)
mm minute (00 to 59)
ss second (00 to 59)
TZD time zone designator (Z or +hh:mm or -hh::mm)
Index
date, 34 linearization, 6
defined, 77
decompressing, 23 malformed file, 8
decryption, 3, 21 media box, 18
dictionary merging, 11
79
80 Index
metadata, 47 units, 5
XMP, 50 user password, 3
page
duplicate, 3
labels, 52
layout, 50
mode, 51
numbers, 35
range, 2
size, 16
pages
collate, 12
password, 3
presentations, 31
printer’s marks, 20
producer, 6
range, 2
removing text, 34
reversing, 2
rotate
contents, 18
pages, 17
scale pages, 16
shift page contents, 17
splitting, 12
on bookmarks, 12
spot colour, 74
squeeze, 24
stamp text, 34
standard input, 4
standard output, 4
text
convert to PDF, 69
encodings, 10
time, 34
trim marks, 20
two-up, 42