StructTreeRoot Class Documentation

class StructTreeRoot

Namespace:datalogics_interface

Detailed Description

Internal wrapper for the root of a PDF logical structure tree.

Owns a non-owning reference to its CDocument. The underlying PDF structure tree is owned by the document; this wrapper provides C++ access to catalog- level struct tree operations (add children, access the backing dict).

Root of the PDF logical structure tree. Obtained exclusively via Document::create_struct_tree_root() or Document::get_struct_tree_root().

Threading: single-thread use. A StructTreeRoot is bound to its owning Document's thread; do not share it across threads. See datalogics_interface.hpp for the full threading model.

Lifetime: a StructTreeRoot must not outlive the Document that produced it.

Referenced by

Constructor & Destructor Documentation

~StructTreeRoot

~StructTreeRoot()

Member Function Documentation

add_child

StructElement add_child(const std::string & struct_type)

Parameters

struct_type: const std::string &

Returns:

StructElement

Create and append a top-level child element with the given struct type.

as_pdf_object

PDFObject as_pdf_object()

Returns:

PDFObject

Non-owning handle suitable for use in dicts/arrays as an indirect reference. The StructTreeRoot dict is always indirect.

get_kid

StructElement get_kid(size_t index)

Parameters

index: size_t

Returns:

StructElement

Top-level kid at index. Always a struct element per the PDF spec.

Exceptions

std::out_of_range
—

if index is not less than get_kid_count().

get_kid_count

size_t get_kid_count()

Returns:

size_t

Number of top-level kids on this tree root. Per the PDF spec, all kids of a tree root are struct elements (no MCRs / OBJRs), so the counterpart accessor is get_kid(index).

get_pdf_dict

PDFDict get_pdf_dict()

Returns:

PDFDict

Returns the raw catalog-side dict for this StructTreeRoot — used as the escape hatch for /RoleMap, /IDTree, /ParentTreeNextKey and any other entry without a dedicated accessor.