NormalizeStructTree

Tagged PDF, structure repair

Description

Canonicalises every structure child collection as an array, promotes direct structure elements to indirect objects, repairs child /P links, removes invalid scalar kids, and keeps only the first reachable edge when a duplicate or cycle is encountered

Syntax

Delphi

Function TPDFlib.NormalizeStructTree: Integer;

ActiveX

Function PDFlib::NormalizeStructTree() As Long

DLL

int DLNormalizeStructTree(int InstanceID);

Return values

-1The selected document has no structure tree
0The tree was already canonical
NThe positive number of repaired edges, collections, references, or promoted objects

Remarks

The traversal is iterative and linear in the number of reachable structure kids. Numeric MCIDs and valid /MCR or /OBJR dictionaries are preserved in place, so existing page /StructParents and /ParentTree mappings remain valid