PDFString Class Documentation

class PDFString : PDFObject

Namespace:datalogics_interface

Inherits from:
PDFObject

Detailed Description

Represents an array of unsigned bytes within a PDF document.

A PDFString is a single data element that represents an array of unsigned bytes. It may be inserted into any collection object. PDFString may be a string of human readable text, but this is not required, and it may be stored either as characters or as hex values.

Uses types

Constructor & Destructor Documentation

PDFString

PDFString(const std::string & value, Document & doc, bool indirect, bool stored_as_hex)

Parameters

value: const std::string &

Array of bytes stored in this PDFString

doc: Document &

Document object containing this PDFString

indirect: bool

flag marking this as an indirect PDFObject

stored_as_hex: bool

flag indicating this PDFString should be stored as hex values

General constructor

Member Function Documentation

get_bytes

std::vector< unsigned char > get_bytes()

Returns:

std::vector< unsigned char >

A byte array containing the raw data of this PDFString.

The raw byte array of this PDFString.

This method returns the raw data of the PDFString, without respect to any encoding. It should be used when the contents of the object represent data instead of human readable text, or when direct access to the underlying data is required.

get_generation

int get_generation()

Returns:

int

The 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:

int

The 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:

bool

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

Indicates if this object is indirect or direct.

get_stored_as_hex

bool get_stored_as_hex()

Returns:

bool

true if this PDFString is stored as hex values, false otherwise.

Indicates that the data is stored as hexadecimal values.

get_type

PDFObjectType get_type()

Returns:

PDFObjectType

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

get_value

std::string get_value()

Returns:

std::string

The string value of this PDFString, converted to a Unicode string.

The byte array as a native string object.

This is a convenience for typical uses where a PDFString holds a human readable string instead of a byte array.

The text may be encoded within the PDF as either UTF-16BE or PDFDocEncoding; in either case, it will be converted to a Unicode string object appropriate to the platform.

If you need to access the contents of the PDFString object without respect to an encoding, use the Bytes property.

operator==

bool operator==(const PDFObject & other)

Parameters

other: const PDFObject &

The other PDFObject to compare against.

Returns:

bool

true if the two objects are equal, false otherwise.

Compare if two objects are equal.

to_string

std::string to_string()

Returns:

std::string

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