pikepdf API¶
Main objects¶
-
class
pikepdf.
ObjectStreamMode
¶ Options for saving object streams within PDFs, which are more a compact way of saving certains types of data that was added in PDF 1.5. All modern PDF viewers support object streams, but some third party tools and libraries cannot read them.
-
disable
¶ Disable the use of object streams. If any object streams exist in the file, remove them when the file is saved.
-
preserve
¶ Preserve any existing object streams in the original file. This is the default behavior.
-
generate
¶ Generate object streams.
-
-
class
pikepdf.
StreamDecodeLevel
¶ -
none
¶ Do not attempt to apply any filters. Streams remain as they appear in the original file. Note that uncompressed streams may still be compressed on output. You can disable that by calling setCompressStreams(false).
-
generalized
¶ This is the default. libqpdf will apply LZWDecode, ASCII85Decode, ASCIIHexDecode, and FlateDecode filters on the input. When combined with setCompressStreams(true), which the default, the effect of this is that streams filtered with these older and less efficient filters will be recompressed with the Flate filter. As a special case, if a stream is already compressed with FlateDecode and setCompressStreams is enabled, the original compressed data will be preserved.
-
specialized
¶ In addition to uncompressing the generalized compression formats, supported non-lossy compression will also be be decoded. At present, this includes the RunLengthDecode filter.
-
all
¶ In addition to generalized and non-lossy specialized filters, supported lossy compression filters will be applied. At present, this includes DCTDecode (JPEG) compression. Note that compressing the resulting data with DCTDecode again will accumulate loss, so avoid multiple compression and decompression cycles. This is mostly useful for retrieving image data.
-
Object construction¶
Support models¶
-
class
pikepdf.models.
EncryptionMethod
¶ Describes which encryption method was used on a particular part of a PDF. These values are returned by
pikepdf.EncryptionInfo
but are not currently used to specify how encryption is requested.-
none
¶ Data was not encrypted.
-
unknown
¶ An unknown algorithm was used.
-
rc4
¶ The RC4 encryption algorithm was used (obsolete).
-
aes
¶ The AES-based algorithm was used as described in the PDF 1.7 reference manual.
-
aesv3
¶ An improved version of the AES-based algorithm was used as described in the Adobe Supplement to the ISO 32000, requiring PDF 1.7 extension level 3. This algorithm still uses AES, but allows both AES-128 and AES-256, and improves how the key is derived from the password.
-
Internal objects¶
These objects are returned by other pikepdf objects. They are part of the API, but not intended to be created explicitly.