THotPDF.AddPDFVTNode Method
Declares one node of the PDF/VT document part hierarchy, optionally with its document part metadata, and returns the handle the deeper nodes and the page ranges refer to
Declaration
function AddPDFVTNode(ParentNode: Integer;
DPM: THPDFDictionaryObject): Integer;
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
ParentNode | -1 for the root of the hierarchy, or the handle an earlier call returned for the immediate ancestor |
DPM | The §6.6 document part metadata dictionary, or nil when the node carries none |
Return value
The node handle, for use as the ParentNode of a deeper node or as the Node argument of SetPDFVTNodePages
Usage notes
- ISO 16612-2:2010 §6.5 requires the DPart dictionaries to form a tree with exactly one root, so
ParentNodeis either-1or a handle this method already returned, andEndDocraises when two nodes were declared with-1 - Because a parent has to exist before a child can name it, the nodes are stored in ancestor-before-descendant order and
EndDocderives each depth from its parent chain - §6.5 Table 4 makes
/DPartsand/Startmutually exclusive: a node that already carries a page range refuses a child here, and a node that already has children refuses a range inSetPDFVTNodePages, so only leaf nodes reference pages - This method takes ownership of
DPM, so the caller must not free it; a dictionary thatEndDocnever emitted is released by the destructor, whilst one that reached emission belongs to the DPart dictionary that carries it - §6.6 forbids a child node from inheriting the document part metadata of its parent, so a
DPMapplies to the node it was declared with and to nothing below it - Every key of the
DPM, of every dictionary contained in it and of every dictionary referenced from it has to be an XML NMTOKEN after#XXescape expansion, and no two keys of one dictionary may collide after that expansion, because Annex D uses the keys verbatim as XML attribute and element names; both rules are checked here, at every depth, bounded at 32 dictionaries so a self-referential object graph cannot exhaust the stack GTS_ManagedandGTS_Suspecthave to be dictionaries when present, and that requirement is applied to the expanded spelling of the key, so#5Ffor the underscore names the same entry- §6.7
GTS_XIDandGTS_Scopeare should-level and are not checked, so a caller may put them in aDPMunder the same key rules - The
DPMmay be a direct dictionary built withAddStringValueand friends, or an indirect one already added to the document; an indirect dictionary is referenced by number and stays where the caller put it