PDFStream Class Documentation
class PDFStream : PDFObjectNamespace:datalogics_interface
- Inherits from:
PDFObject
Detailed Description
Represents a stream of data within a PDF document.
All objects in a PDF document are built from a collection of simpler objects that represent fundamental datatypes like numbers, strings and arrays.
PDFObject and its subclasses allow direct access and manipulation of these simple objects. Some subclasses represent single data elements (e.g. PDFInteger represents a single integer value); other subclasses represent a collection of PDFObjects (e.g. PDFArray is an indexed array of data elements).
A PDFStream represents a stream of unsigned bytes, and may be inserted into any collection object. It includes a dictionary that describes how the data in the stream is encoded and other useful information about the stream. A PDFStream is always an indirect object.
PDFStreams can be encoded using built-in filters. These filters include compression schemes for most popular image formats, and text encoding translators to permit safe transmission of the document over the Internet. The data in a PDFStream will be automatically encoded when it is created; the user can read either the encoded (raw) or decoded (filtered) data.
PDFStreams can be used for any large collection of data that need not be read into memory all at once, including image data, multimedia data or XML markup.
Referenced by
Uses types
Constructor & Destructor Documentation
PDFStream
PDFStream(std::istream & input, Document & doc)Parameters
input: std::istream &doc: Document &
Create a PDFStream from an input stream in the given document. The stream data is read during construction.
PDFStream
PDFStream(std::istream & input, Document & doc, PDFDict & encoding_dict, PDFArray & encoding_params)Parameters
input: std::istream &doc: Document &encoding_dict: PDFDict &encoding_params: PDFArray &
Create a PDFStream from an input stream with encoding parameters. encoding_dict and encoding_params control compression/filters.
Member Function Documentation
get_dict
std::unique_ptr< PDFDict > get_dict()Returns:
std::unique_ptr< PDFDict >The stream's encoding dictionary.
Retrieve the encoding dictionary for this stream (contains /Filter, /DecodeParms, and any other stream metadata). The encoding dictionary for the stream. This includes all required information for decoding the stream, such as filter names and decode parameters.
get_filtered_bytes
std::vector< unsigned char > get_filtered_bytes()Returns:
std::vector< unsigned char >Read the stream's filtered (decoded) bytes after applying the stream's /Filter and /DecodeParms. Use this for content streams, XMP, images.
get_generation
int get_generation()Returns:
intThe generation number of this indirect object.
The generation number for this object.
Only indirect objects have a generation number.
get_id
int get_id()Returns:
intThe ID number of this indirect object.
The ID number for this object.
Only indirect objects have an ID number.
get_indirect
bool get_indirect()Returns:
booltrue if this object is indirect, false if it is direct.
Indicates if this object is indirect or direct.
get_length
long get_length()Returns:
longThe length of the encoded (raw) stream data.
The encoded length of the stream in bytes.
get_raw_bytes
std::vector< unsigned char > get_raw_bytes()Returns:
std::vector< unsigned char >Read the stream's raw (encoded, still compressed) bytes — what is actually stored in the PDF file. Use this for signature/XRef work where you need the on-disk bytes.
get_type
PDFObjectType get_type()Returns:
PDFObjectTypeThe underlying Cos type of this object. Prefer this over dynamic_cast/try_as chains in hot paths.
operator!=
bool operator!=(const PDFObject & other)Parameters
other: const PDFObject &
Returns:
booltrue if other is not equal to this.
Inequality.
operator==
bool operator==(const PDFObject & other)Parameters
other: const PDFObject &The other PDFObject to compare against.
Returns:
booltrue if the two objects are equal, false otherwise.
Compare if two objects are equal.
to_string
std::string to_string()Returns:
std::stringA string describing this PDFObject.
Returns a string representation of this PDFObject.
The string includes the object's indirect status, and if indirect, its ID and generation number.
try_as
T * try_as(typename T )Parameters
: typename T
Returns:
T *Attempt to downcast this object to a derived Cos type such as PDFString, PDFDict, PDFArray, PDFStream, PDFName, PDFInteger, PDFReal, or PDFBoolean. Returns nullptr if the object's actual type doesn't match T.
try_as
const T * try_as(typename T )Parameters
: typename T
Returns:
const T *Const overload of try_as(). Returns a const pointer, or nullptr.