cpdf -info [-raw | -utf8] in.pdf
cpdf -page-info in.pdf
cpdf -pages in.pdf
cpdf -set-title <title of document>
[-also-set-xmp] [-just-set-xmp] [-raw] in.pdf -o out.pdf
(Also -set-author etc. See Section 11.2.)
cpdf -set-page-layout <layout> in.pdf -o out.pdf
cpdf -set-page-mode <mode> in.pdf -o out.pdf
cpdf -hide-toolbar <true | false> in.pdf -o out.pdf
-hide-menubar
-hide-window-ui
-fit-window
-center-window
-display-doc-title
cpdf -open-at-page <page number> in.pdf -o out.pdf
cpdf -open-at-page-fit <page number> in.pdf -o out.pdf
cpdf -set-metadata <metadata-file> in.pdf -o out.pdfcpdf -remove-metadata in.pdf -o out.pdf
cpdf -print-metadata in.pdf
cpdf -create-metadata in.pdf -o out.pdf
cpdf -set-metadata-date <date> in.pdf -o out.pdf
cpdf -add-page-labels in.pdf -o out.pdf
[-label-style <style>] [-label-prefix <string>]
[-label-startval <integer>] [-labels-progress]
cpdf -remove-page-labels in.pdf -o out.pdf
cpdf -print-page-labels in.pdf
The -info operation prints entries from the document information dictionary, and from any XMP metadata to standard output.
$cpdf -info pdf_reference.pdf Encryption: 40bit Linearized: true Permissions: No edit Version: 1.6 Pages: 1310 Title: PDF Reference, version 1.7 Author: Adobe Systems Incorporated Subject: Adobe Portable Document Format (PDF) Keywords: Creator: FrameMaker 7.2 Producer: Acrobat Distiller 7.0.5 (Windows) Created: D:20061017081020Z Modified: D:20061118211043-0230 XMP pdf:Producer: Adobe PDF library 7.77 XMP xmp:CreateDate: 2006-12-21T18:19:09+01:00 XMP xmp:CreatorTool: Adobe Illustrator CS2 XMP xmp:MetadataDate: 2006-12-21T18:19:09Z XMP xmp:ModifyDate: 2006-12-21T18:19:09Z XMP dc:title: AI6
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.
$cpdf -page-info 14psfonts.pdf Page 1: Label: i MediaBox: 0.000000 0.000000 600.000000 450.000000 CropBox: 200.000000 200.000000 500.000000 500.000000 BleedBox: TrimBox: ArtBox: Rotation: 0
Note that the format for boxes is minimum x, minimum y, maximum x, maximum y.
The -pages operation prints the number of pages in the file.
cpdf -pages Archos.pdf 8
The document information dictionary in a PDF file specifies various pieces of information about a PDF. These can be consulted in a PDF viewer (for instance, Acrobat).
Here is a summary of the commands for setting entries in the document information dictionary:
(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
cpdf -set-title "A Night in London" in.pdf -o out.pdf
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.
PDF files can contain a piece of arbitrary metadata, often in XMP format. This is typically stored in an uncompressed stream, so that other applications can read it without having to decode the whole PDF. To set the metadata:
cpdf -set-metadata data.xml in.pdf -o out.pdf
cpdf -remove-metadata in.pdf -o out.pdf
cpdf -print-metadata in.pdf
cpdf -create-metadata in.pdf -o out.pdf
cpdf -set-metadata-date <date> in.pdf -o out.pdf
The -set-page-layout operation specifies the page layout to be used when a document is opened in, for instance, Acrobat. The possible (case-sensitive) values are:
For instance:
cpdf -set-page-layout TwoColumnRight in.pdf -o out.pdf
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:
cpdf -remove-dict-entry /OpenAction in.pdf -o out.pdf
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:
cpdf -set-page-mode FullScreen in.pdf -o out.pdf
For instance:
cpdf -hide-toolbar true in.pdf -o out.pdf
The page a PDF file opens at can be set using -open-at-page:
cpdf -open-at-page 15 in.pdf -o out.pdf
To have that page scaled to fit the window in the viewer, use -open-at-page-fit instead:
cpdf -open-at-page-fit end in.pdf -o out.pdf
(Here, we used end to open at the last page. Any page specification describing a single page is ok here.)
It is possible to add page labels to a document. These are not the printed on the page, but may be displayed alongside thumbnails or in print dialogue boxes by PDF readers. We use -add-page-labels to do this, by default with decimal arabic numbers (1,2,3…). We can add -label-style to choose what type of labels to add from these kinds:
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:
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
Here are the commands, in order:
cpdf -add-page-labels in.pdf 1-4 -label-style LowercaseRoman
-o out.pdf
cpdf -add-page-labels out.pdf 5-14 -o out.pdf
cpdf -add-page-labels out.pdf 15-20 -label-prefix "A-"
-label-startval 0 -o out.pdf
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:
$ cpdf -print-page-labels cpdfmanual.pdf labelstyle: LowercaseRoman labelprefix: None startpage: 1 startvalue: 1 labelstyle: DecimalArabic labelprefix: None startpage: 9 startvalue: 1