}
        } else {
            // the kid is another StructElement node.
            ProcessStructElement2($element->GetAsStructElem($i), $mcid_doc_map, $ident + 1);
        }
    }
    PrintIdent($ident);
    echo "</" . $element->GetType() . ">";
}
PDFNet::Initialize();
// Extract logical structure from a PDF document
$doc = new PDFDoc($input_path . "tagged.pdf");
$doc->InitSecurityHandler();
echo nl2br("____________________________________________________________\n");
echo nl2br("Sample 1 - Traverse logical structure tree...\n");
$tree = $doc->GetStructTree();
if ($tree->IsValid()) {
    echo nl2br("Document has a StructTree root.\n");
    for ($i = 0; $i < $tree->GetNumKids(); ++$i) {
        // Recursively get structure info for all child elements.
        ProcessStructElement($tree->GetKid($i), 0);
    }
} else {
    echo nl2br("This document does not contain any logical structure.\n");
}
echo nl2br("\nDone 1.\n");
echo nl2br("____________________________________________________________\n");
echo nl2br("Sample 2 - Get parent logical structure elements from\n");
echo nl2br("layout elements.\n");
$reader = new ElementReader();
for ($itr = $doc->GetPageIterator(); $itr->HasNext(); $itr->Next()) {