Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

DynaPDF Manual - Page 429

Previous Page 428   Index   Next Page 430

Function Reference
Page 429 of 766
begin
if Level > 32 then Exit; // A maximum recursion depth of 32 should be more than enough.
node.StructSize := sizeof(node);
ocg.StructSize
:= sizeof(ocg);
saved := Parent;
while Next <> nil do begin
node.NextChild := nil;
node.OCG
:= -1;
Next
:= FPDF.GetOCUINode(Next, @node);
if node.OCG < 0 then begin
lbl := GetString(node.LabelA, node.LabelW);
if node.NewNode then
prnt := LayerTree.Items.AddNode(nil, Parent, lbl, nil, naAddChild)
else
prnt := Parent;
LoadLayerTreeNodes(prnt, node.NextChild, Level +1);
Parent := saved; // Important! Restore the parent tree node.
end else begin
if FPDF.GetOCG(node.OCG, ocg) then begin
lbl := GetString(ocg.NameA, ocg.NameW);
if node.NewNode then begin
saved
:= Parent; // Important! Save the parent tree node.
Parent := LayerTree.Items.AddNode(nil, Parent, lbl, nil, naAddChild)
end else
LayerTree.Items.AddNode(nil, Parent, lbl, nil, naAddChild);
end;
end;
end;
end;
procedure TForm1.LoadLayerTree;
var next: IOCN;
begin
FPDF.ImportOCProperties;
// Import the global Optional Content Properties
FPDF.LoadLayerConfig(-1);
// Load the default layer configuration
next := FPDF.GetOCUINode(nil, nil);
// Get the root node
LoadLayerTreeNodes(nil, next, 0);
// Load the children of the root
end;
Although the syntax is slightly different among different programming languages, the general
algorithm stays the same.
 

Previous topic: GetOCUINode

Next topic: GetOutputIntent