2022-03-07 18:16:03 +01:00
|
|
|
CHAPTER 1. Basics
|
|
|
|
|
|
|
|
Cpdf.fromFile(String, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Loads a PDF file from a given file. Supply a user password (possibly blank) in
|
|
|
|
case the file is encrypted. It won't be decrypted, but sometimes the password
|
|
|
|
is needed just to load the file.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.fromFileLazy(String, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Loads a PDF from a file, doing only minimal parsing. The objects will be read
|
|
|
|
and parsed when they are actually needed. Use this when the whole file won't be
|
|
|
|
required. Also supply a user password (possibly blank) in case the file is
|
|
|
|
encrypted. It won't be decrypted, but sometimes the password is needed just to
|
|
|
|
load the file.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.fromMemory(Byte[], String)
|
|
|
|
|
|
|
|
Loads a file from memory given any user password.
|
|
|
|
|
|
|
|
Cpdf.fromMemoryLazy(IntPtr, Int32, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Loads a file from memory, given a pointer and a length, and the user password,
|
|
|
|
but lazily like fromFileLazy. The caller must use AllocHGlobal / Marshal.Copy /
|
|
|
|
FreeHGlobal itself. It must not free the memory until the PDF is also gone.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.startEnumeratePDFs
|
|
|
|
|
|
|
|
Cpdf.enumeratePDFsKey(Int32)
|
|
|
|
|
|
|
|
Cpdf.enumeratePDFsInfo(Int32)
|
|
|
|
|
|
|
|
Cpdf.endEnumeratePDFs
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
To enumerate the list of currently allocated PDFs, call startEnumeratePDFs
|
|
|
|
which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and
|
|
|
|
enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to
|
|
|
|
clean up.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.ptOfCm(Double)
|
|
|
|
|
|
|
|
Converts a figure in centimetres to points (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.ptOfMm(Double)
|
|
|
|
|
|
|
|
Converts a figure in millimetres to points (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.ptOfIn(Double)
|
|
|
|
|
|
|
|
Converts a figure in inches to points (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.cmOfPt(Double)
|
|
|
|
|
|
|
|
Converts a figure in points to centimetres (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.mmOfPt(Double)
|
|
|
|
|
|
|
|
Converts a figure in points to millimetres (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.inOfPt(Double)
|
|
|
|
|
|
|
|
Converts a figure in points to inches (72 points to 1 inch)
|
|
|
|
|
|
|
|
Cpdf.parsePagespec(Cpdf.Pdf, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Parses a page specification with reference to a given PDF (the PDF is supplied
|
|
|
|
so that page ranges which reference pages which do not exist are rejected).
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.validatePagespec(String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Validates a page specification so far as is possible in the absence of the
|
|
|
|
actual document. Result is true if valid.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.stringOfPagespec(Cpdf.Pdf, List{Int32})
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Builds a page specification from a page range. For example, the range
|
|
|
|
containing 1, 2, 3, 6, 7, 8 in a document of 8 pages might yield "1-3, 6-end"
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.blankRange
|
|
|
|
|
|
|
|
Creates a range with no pages in.
|
|
|
|
|
|
|
|
Cpdf.range(Int32, Int32)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Builds a range from one page to another inclusive. For example, range(3, 7)
|
|
|
|
gives the range 3, 4, 5, 6, 7
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.all(Cpdf.Pdf)
|
|
|
|
|
|
|
|
The range containing all the pages in a given document.
|
|
|
|
|
|
|
|
Cpdf.even(List{Int32})
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Makes a range which contains just the even pages of another range.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.odd(List{Int32})
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Makes a range which contains just the odd pages of another range.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.rangeUnion(List{Int32}, List{Int32})
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Makes the union of two ranges giving a range containing the pages in range a
|
|
|
|
and range b.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.difference(List{Int32}, List{Int32})
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Makes the difference of two ranges, giving a range containing all the pages in
|
|
|
|
a except for those which are also in b.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.removeDuplicates(List{Int32})
|
|
|
|
|
|
|
|
Deduplicates a range, making a new one.
|
|
|
|
|
|
|
|
Cpdf.rangeLength(List{Int32})
|
|
|
|
|
|
|
|
Gives the number of pages in a range.
|
|
|
|
|
|
|
|
Cpdf.rangeGet(List{Int32}, Int32)
|
|
|
|
|
|
|
|
Gets the page number at position n in a range,
|
|
|
|
where n runs from 0 to rangeLength - 1.
|
|
|
|
|
|
|
|
Cpdf.rangeAdd(List{Int32}, Int32)
|
|
|
|
|
|
|
|
Adds the page to a range, if it is not already
|
|
|
|
there.
|
|
|
|
|
|
|
|
Cpdf.isInRange(List{Int32}, Int32)
|
|
|
|
|
|
|
|
Returns true if the page is in the range,
|
|
|
|
false otherwise.
|
|
|
|
|
|
|
|
Cpdf.pages(Cpdf.Pdf)
|
|
|
|
|
|
|
|
Returns the number of pages in a PDF.
|
|
|
|
|
|
|
|
Cpdf.pagesFast(String, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Returns the number of pages in a given PDF, with given user password. It tries
|
|
|
|
to do this as fast as possible, without loading the whole file.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.toFile(Cpdf.Pdf, String, Boolean, Boolean)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Writes the file to a given filename. If linearize is true, it will be
|
|
|
|
linearized if a linearizer is available. If make_id is true, it will be given a
|
|
|
|
new ID.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.toFileExt(Cpdf.Pdf, String, Boolean, Boolean, Boolean, Boolean, Boolean)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Writes the file to a given filename. If make_id is true, it will be given a new
|
|
|
|
ID. If preserve_objstm is true, existing object streams will be preserved. If
|
|
|
|
generate_objstm is true, object streams will be generated even if not
|
|
|
|
originally present. If compress_objstm is true, object streams will be
|
|
|
|
compressed (what we usually want). WARNING: the pdf argument will be invalid
|
|
|
|
after this call, and should be not be used again.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.toMemory(Cpdf.Pdf, Boolean, Boolean)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Writes a PDF file and returns as an array of bytes.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.isEncrypted(Cpdf.Pdf)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Returns true if a documented is encrypted, false otherwise.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.decryptPdf(Cpdf.Pdf, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Attempts to decrypt a PDF using the given user password. An exception is raised
|
|
|
|
if the decryption fails.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.decryptPdfOwner(Cpdf.Pdf, String)
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Attempts to decrypt a PDF using the given owner password. Raises an exception
|
|
|
|
if the decryption fails.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.Permission
|
|
|
|
|
|
|
|
Permissions
|
|
|
|
|
|
|
|
Cpdf.Permission.NoEdit
|
|
|
|
|
|
|
|
Cannot edit the document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoPrint
|
|
|
|
|
|
|
|
Cannot print the document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoCopy
|
|
|
|
|
|
|
|
Cannot copy the document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoAnnot
|
|
|
|
|
|
|
|
Cannot annotate the document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoForms
|
|
|
|
|
|
|
|
Cannot edit forms in the document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoExtract
|
|
|
|
|
|
|
|
Cannot extract information
|
|
|
|
|
|
|
|
Cpdf.Permission.NoAssemble
|
|
|
|
|
|
|
|
Cannot assemble into a bigger document
|
|
|
|
|
|
|
|
Cpdf.Permission.NoHqPrint
|
|
|
|
|
|
|
|
Cannot print high quality
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod
|
|
|
|
|
|
|
|
Encryption methods
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Pdf40bit
|
|
|
|
|
|
|
|
40 bit RC4 encryption
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Pdf128bit
|
|
|
|
|
|
|
|
128 bit RC4 encryption
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes128bitfalse
|
|
|
|
|
|
|
|
128 bit AES encryption, do not encrypt metadata
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes128bittrue
|
|
|
|
|
|
|
|
128 bit AES encryption, encrypt metadata
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes256bitfalse
|
|
|
|
|
|
|
|
Deprecated. Do not use for new files
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes256bittrue
|
|
|
|
|
|
|
|
Deprecated. Do not use for new files
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes256bitisofalse
|
|
|
|
|
|
|
|
256 bit AES encryption, do not encrypt metadata
|
|
|
|
|
|
|
|
Cpdf.EncryptionMethod.Aes256bitiosotrue
|
|
|
|
|
|
|
|
256 bit AES encryption, encrypt metadata
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Cpdf.toFileEncrypted(Cpdf.Pdf, Cpdf.EncryptionMethod, List{Cpdf.Permission},
|
|
|
|
String, String, Boolean, Boolean, String)
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Writes a file as encrypted.
|
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Cpdf.toFileEncryptedExt(Cpdf.Pdf, Cpdf.EncryptionMethod, List{Cpdf.Permission},
|
|
|
|
String, String, Boolean, Boolean, Boolean, Boolean, Boolean, String)
|
2022-03-07 18:16:03 +01:00
|
|
|
|
2022-03-09 13:07:27 +01:00
|
|
|
Writes a file as encrypted with extra parameters. WARNING: the pdf argument
|
|
|
|
will be invalid after this call, and should not be used again.
|
2022-03-07 18:16:03 +01:00
|
|
|
|
|
|
|
Cpdf.hasPermission(Cpdf.Pdf, Cpdf.Permission)
|
|
|
|
|
|
|
|
Returns true if the given permission
|
|
|
|
(restriction) is present.
|
|
|
|
|
|
|
|
Cpdf.encryptionKind(Cpdf.Pdf)
|
|
|
|
|
|
|
|
Returns the encryption method currently in use on
|
|
|
|
a document.
|