PDFStream Class Documentation

classPDFStream : PDFObject

Namespace:datalogics_interface

Inherits from:
PDFObject

Detailed Description

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.

Constructor & Destructor Documentation

PDFStream

PDFStream(std::istream &input, Document &doc)

Parameters

input: std::istream &

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 &
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

Returns:

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

intget_generation()

Returns:

The generation number of this indirect object.

Only indirect objects have a generation number.

get_id

intget_id()

Returns:

The ID number of this indirect object.

Only indirect objects have an ID number.

get_indirect

boolget_indirect()

Returns:

true if this object is indirect, false if it is direct.

Indicates if this object is indirect or direct.

get_length

longget_length()

Returns:

The 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

PDFObjectTypeget_type()

Returns:

PDFObjectType

The underlying Cos type of this object. Prefer this over dynamic_cast/try_as chains in hot paths.

operator==

booloperator==(const PDFObject &other)

Parameters

other: const PDFObject &

The other PDFObject to compare against.

Returns:

true if the two objects are equal, false otherwise.

Compare if two objects are equal.

to_string

std::stringto_string()

Returns:

A string describing 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.