1.3. WORKING WITH ENCRYPTED DOCUMENTS
cpdf in.pdf ˜3-˜1 -o out.pdf
Extract the last three pages of a document, in order.
1.3 Working with Encrypted Documents
In order to perform many operations, encrypted input PDF ﬁles must be decrypted. Some
require the owner password, some either the user or owner passwords. Either password is
supplied by writinguser=<password> orowner=<password> following each input ﬁle
requiring it(before or after any range). The document will not be re-encrypted upon writing.
cpdf in.pdf user=charles -info
cpdf in.pdf owner=fred reverse -o out.pdf
To re-encrypt the ﬁle with its existingencryption upon writing, which is requiredif only the
user password was supplied, but allowed in anycase,add the-recrypt option:
cpdf in.pdf user=fred reverse -recrypt -o out.pdf
Thepassword required (owner or user) dependsupon the operationbeing performed. Separate
facilitiesare provided todecrypt and encrypt ﬁles (See Section 4).
1.4 Standard Input and Standard Output
Thus far, we have assumed that the input PDF will beread from a ﬁleon disk,and the output
written similarly. Often it’s useful to be able to read input fromstdin (Standard Input) or
write output tostdout (Standard Output) instead. The typical useis to join several programs
together into a pipe,passing data fromone to the nextwithoutthe use ofintermediateﬁles. Use
data between multipleprograms, or multiple invocations of the same program. For example,
this sequenceofcommands (all typed on one line)
cpdf in.pdf reverse -stdout |
cpdf -stdin 1-5 -stdout |
cpdf -stdin reverse -o out.pdf
extracts the last ﬁve pages ofin.pdf in the correct order, writing them toout.pdf. It does
this byreversing theinput, taking theﬁrst ﬁvepages and then reversingthe result.
Pdf metadata reader - add, remove, update PDF metadata in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Allow C# Developers to Read, Add, Edit, Update and Delete PDF Metadatapdf metadata viewer online; read pdf metadata java
Pdf metadata reader - VB.NET PDF metadata library: add, remove, update PDF metadata in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Enable VB.NET Users to Read, Write, Edit, Delete and Update PDF Document Metadatapdf xmp metadata; acrobat pdf additional metadata
CHAPTER 1. BASIC USAGE
To supply passwords for a ﬁle from-stdin, use-stdin-owner <password> and/or
Using-stdout on the ﬁnal command in the pipeline to output the PDF to screen is not
recommended,sincePDF ﬁles often containcompressed sectionswhich arenot screen-readable.
Severalcpdf operations write to standard outputby default (forexample, listing fonts). A
useful feature of thecommand line (not speciﬁc tocpdf) isthe abilityto redirect this outputto
aﬁle. This is achieved with the > operator:
cpdf -info in.pdf > file.txt
Usethe -info operation (SeeSection 11.2), redirecting the outputto file.txt.
1.5 Doing several things at once with AND
The keywordAND can be used to string together several commands in one. The advantage
compared with usingpipesis thatthe ﬁle need not berepeatedlyparsed and written out, saving
To useAND, simply leave off theoutput speciﬁer(e.g-o) of one command,and the input
speciﬁer(e.gﬁlename) of thenext. Forinstance:
cpdf -merge in.pdf in2.pdf AND -add-text "Label"
AND -merge in3.pdf -o out.pdf
Mergein.pdf andin2.pdf together, add text to both pages, appendin3.pdf and write to
To specify therange foreach section, use-range:
cpdf -merge in.pdf in2.pdf AND -range 2-4 -add-text "Label"
AND -merge in3.pdf -o out.pdf
When measurements are given tocpdf, they are in points (1 point = 1/72 inch). They may
optionally befollowed bysomelettersto changethemeasurement. Thefollowingaresupported:
pt Points (72 points per inch). Thedefault.
How to C#: Modify Image Metadata (tag)
XImage.Barcode Reader. XImage.Barcode Generator. C#.NET rotate PDF pages, C#.NET search text in PDF, C#.NET edit PDF bookmark, C#.NET edit PDF metadata, C#.NET modify pdf metadata; add metadata to pdf
1.7. PDF VERSION NUMBERS
1.7 PDF Version Numbers
When an operation which uses a part of the PDF standard which was introduced in a later
version than that of the input ﬁle, the PDF version in the output ﬁle is setto the later version
(mostPDF viewers will tryto loadanyPDFﬁle,evenifitismarked with alater version number).
However, this automatic version changing maybesuppressed with the-keep-version ﬂag.
Here isa list ofAcrobatversions together with themaximum PDFversion they are intended
PDF1.2 Acrobat 3.0
PDF1.3 Acrobat 4.0
PDF1.4 Acrobat 5.0
PDF1.5 Acrobat 6.0
PDF1.6 Acrobat 7.0
PDF1.7 Acrobat 8.0,9.0,10.0
Ifyou wish to manuallyalter thePDFversion ofa ﬁle, usethe-set-version optiondescribed
in Section 15.5.
1.8 File IDs
PDFﬁles contain an ID(consistingoftwoparts),used by someworkﬂow systems touniquely
identify a ﬁle. Tochange the ID,behavior, use the-change-id operation. This will create a
new ID forthe outputﬁle.
cpdf -change-id in.pdf -o out.pdf
Write in.pdf to out.pdf, changing theID.
Linearized PDF isa version ofthe PDF format in which thedata is held in a special manner to
allow content tobe fetchedonly when needed. This means viewing a multipage PDF over a
slow connection ismoreresponsive. Bydefault,cpdf does not linearizeoutput ﬁles. To makeit
doso, add the-l option to the command line, in addition toany othercommand being used.
cpdf -l in.pdf -o out.pdf
Linearize the ﬁle in.pdf, writingto out.pdf.
This requirestheexistenceoftheexternal programcpdflinwhichisprovidedwithcommercial
versionsofcpdf. Thismustbeinstalled as described intheinstallationdocumentationprovided
with your copyofcpdf. If you are unable to installcpdflin, you must use-cpdflin to let
cpdf know wheretoﬁnd it:
CHAPTER 1. BASIC USAGE
cpdf.exe -cpdflin "C:\\cpdflin.exe" -l in.pdf -o out.pdf
Linearize the ﬁle in.pdf, writing toout.pdf.
In extremis, you may placecpdflin 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.
1.10 Object Streams
PDF 1.5 introduced a new mechanism for storing objects to save space: object streams. by
default,cpdf will preserve object streams in input ﬁles, creating no more. To prevent the
retention of existingobject streams, use-no-preserve-objstm:
cpdf -no-preserve-objstm in.pdf -o out.pdf
Writethe ﬁlein.pdf to out.pdf, removingany object streams.
To createnew objectstreams if none exist, or augmenttheexisting ones, use-create-objstm:
cpdf -create-objstm in.pdf -o out.pdf
Write the ﬁlein.pdf toout.pdf, preservingany existingobject streams, and creatinganynewones
fornew objects which have been added.
To create wholly new objectstreams,use both options together:
cpdf -create-objstm -no-preserve-objstm in.pdf -o out.pdf
Writethe ﬁlein.pdf to out.pdf with whollynew object streams.
Files written with object streams will be set to PDF 1.5 or higher, unless-keep-version is
1.11 Malformed Files
There are many malformed PDF ﬁles in existence, including many produced by otherwise-
reputable applications. cpdf attempts to correct these problems silently.
Grossly malformed ﬁles will be reconstructed. The reconstruction progress is shown on
stderr (Standard Error):
1.12. ERROR HANDLING
./cpdf in.pdf -o out.pdf
couldn’t lex object number
Attempting to reconstruct the malformed pdf in.pdf...
Read 5530 objects
Malformed PDF reconstruction succeeded!
the inputﬁles you areusingareimpeccablyformed, the-fast option added to thecommand
line(or, ifusingAND,to each sectionofthecommand line). Thiswill usecertain shortcuts which
speed up processing, but would fail on badly-produced ﬁles.
The -fast option may be used with:
-rotate-contents -upright -vflip -hflip
-shift -scale -scale-to-fit -scale-contents
-stamp-on -stamp-under -combine-pages
If problems occur, refrain from using-fast.
1.12 Error Handling
Whencpdf encounters an error,it exitswith code 2. An error message is displayed onstderr
(Standard Error). In normal usage, this means it’s displayed on the screen. When a bad or
inappropriate password is given, theexit code is 1.
1.13 Control Files
cpdf -control <filename>
cpdf -args <filename>
Someoperatingsystems have a limiton the length of a command line. To circumventthis, or
simplyfor reasonsof ﬂexibility,a controlﬁlemay bespeciﬁed fromwhich arguments aredrawn.
This ﬁle does not support the full syntax of the command line. Commands are separated by
whitespace, quotation marksmay be used ifan argument contains aspace, and the sequence\"
maybeused to introduce a genuinequotation mark in such an argument.
Several-control arguments may be speciﬁed, and may be mixed in with conventional
command-line arguments. The commands in each control ﬁle are consideredin the orderin
which theyaregiven, after all conventional arguments have beenprocessed. It isrecommended
How to C#: Basic SDK Concept of XDoc.PDF for .NET
XDoc.PDF for .NET supports editing PDF document metadata, like Title, Subject, Author, Creator, Producer, Keywords, Created Date, and Last Modified Date. bulk edit pdf metadata; pdf metadata reader
C# PDF - Read Barcode on PDF in C#.NET
C#.NET rotate PDF pages, C#.NET search text in PDF, C#.NET edit PDF bookmark, C#.NET edit PDF metadata, C#.NET edit C#.NET PDF Barcode Reader & Scanner pdf keywords metadata; adding metadata to pdf
CHAPTER 1. BASIC USAGE
to use-args in all new applications. However, , -control will be supported for legacy
To avoid interference between-control andAND, a new mechanism has been added.
Using-args in place of-control will perform direct textual substitution of the ﬁleinto the
command line, priortoanyother processing.
1.14 String Arguments
Command linesarehandled differentlyon eachoperatingsystem. Some charactersarereserved
with special meanings, even when they occur inside quoted string arguments. To avoid this
problem,cpdf performs processing on string arguments as they are read.
Abackslash is used toindicate thata characterwhich would otherwisebetreated specially
by the command line interpreter is to be treated literally. For example, Unix-like systems
attributea special meaning to theexclamation mark, so the command line
cpdf -add-text "Hello!" in.pdf -o out.pdf
would fail. We must escape the exclamation mark with a backslash:
cpdf -add-text "Hello\!" in.pdf -o out.pdf
Itfollowsthatbackslashesintendedto betakenliterallymustthemselves beescaped (i.e. written
1.15 Text Encodings
Somecpdf commands write text to standardoutput, or readtext from the commandline or
conﬁguration ﬁles. Theseare:
-set-author et al.
Thereare three options to control how the text is interpreted:
Add-utf8 to useUnicode UTF8,-stripped to convertto 7 bit ASCII by dropping any high
characters, or -raw to perform no processing. The default is -stripped.
Merging and Splitting
cpdf -merge in1.pdf [<range>] in2.pdf [<range>] [<more names/ranges>]
[-retain-numbering] [-remove-duplicate-fonts] -o out.pdf
cpdf -split in.pdf -o <format> [-chunk <chunksize>]
cpdf -split-bookmarks <level> in.pdf -o <format>
The-merge operation allow the merging of several ﬁles into one. Ranges can be used to
select onlya subset of pages from each inputﬁlein theoutput. The output ﬁle consists of the
concatenation of all the input pages in the order speciﬁed on the command line. Actually, the
-merge can be omitted, since thisis the default operation of cpdf.
cpdf -merge a.pdf 1 b.pdf 2-end -o out.pdf
Take page one of a.pdf andallbut the ﬁrstpage of b.pdf, merge them andproduce out.pdf.
Mergemaintains bookmarks,named destinations,and name dictionaries.
Forms and other objects whichcannot bemerged are retained if they are from thedocument
which ﬁrst exhibits that feature.
The-retain-numbering optionkeeps thePDF pagenumbering labelsofeach document
intact, rather than renumbering theoutput pages from 1.
The-remove-duplicate-fonts ensures that fonts used in more than one of the inputs
only appearonce in theoutput.
CHAPTER 2. MERGING AND SPLITTING
The-split operation splits a PDF ﬁle into a number of parts which are written toﬁle, their
names being generated froma format. The optional-chunk option allows thenumber of pages
written toeach outputﬁle to be set.
cpdf -split a.pdf -o out%%%.pdf
Splita.pdf to theﬁles out001.pdf, out002.pdf etc.
cpdf -split a.pdf 1 even -chunk 10 -o dir/out%%%.pdf
Splitthe even pages ofa.pdf tothe ﬁlesout001.pdf,out002.pdf etc. with at most ten pages in
each ﬁle. Thedirectory(folder) dir must exist.
If the output format does not provide enough numbers for the ﬁles generated, the result is
unspeciﬁed. The following format operators may be used:
%, %%, %%% etc.
Sequence number padded tothe number of percent signs
Original ﬁlename without extension
Sequence number without padding zeroes
Startpageof this chunk
End page of this chunk
Bookmark name at this page
2.3 Splitting on Bookmarks
The-split-bookmarks <level> operation splits a PDFﬁle into a number of parts, accord-
ing to the page ranges implied by the document’s bookmarks. These parts are then written to
ﬁlewith names generated from thegiven format.
Level 0 denotesthetop-level bookmarks,level 1 the nextlevel (sub-bookmarks)and so on.
So-split-bookmarks 1 creates breaks on level 0 and level 1 boundaries.
cpdf -split-bookmarks 0 a.pdf -o out%%%.pdf
Splita.pdf to theﬁles out001.pdf, out002.pdf on bookmark boundaries.
Now, there may be many bookmarks on a single page (for instance, if paragraphs are book-
marked or therearetwosubsectionsononepage). Thesplitscalculatedby-split-bookmarks
ensurethat each pageappearsin only one oftheoutput ﬁles. Itispossibleto use the@ operators
above,includingoperator @B which expands tothe textof the bookmark:
cpdf -split-bookmarks 0 a.pdf -o @B.pdf
Splita.pdf on bookmark boundaries, using the bookmark textas the ﬁlename.
2.4. ENCRYPTING WITH SPLIT AND SPLIT BOOKMARKS
Thebookmark textused for a nameis converted from unicode to 7 bitASCII, and the following
characters are removed, in addition to any characterwith ASCIIcodeless than 32:
/ ? < > \ :
| " ˆ + =
2.4 Encrypting with Split and Split Bookmarks
Theencryption parametersdescribed inChapter 4maybeaddedto thecommand lineto encrypt
each split PDF. Similarly, the-recrypt switch described in 1 may by given to re-encrypt each
ﬁle with the existingencryption ofthesource PDF.
CHAPTER 2. MERGING AND SPLITTING
Documents you may be interested
Documents you may be interested