function AnnotationHighLevelAPI($doc)
{
    // The following code snippet traverses all annotations in the document
    echo nl2br("Traversing all annotations in the document...\n");
    $page_num = 1;
    for ($itr = $doc->GetPageIterator(); $itr->HasNext(); $itr->Next()) {
        echo nl2br("Page " . $page_num++ . ": \n");
        $page = $itr->Current();
        $num_annots = $page->GetNumAnnots();
        for ($i = 0; $i < $num_annots; ++$i) {
            $annot = $page->GetAnnot($i);
            if (!$annot->IsValid()) {
                continue;
            }
            echo "Annot Type: " . $annot->GetSDFObj()->Get("Subtype")->Value()->GetName();
            $bbox = $annot->GetRect();
            echo nl2br("  Position: " . $bbox->x1 . ", " . $bbox->y1 . ", " . $bbox->x2 . ", " . $bbox->y2 . "\n");
            switch ($annot->GetType()) {
                case Annot::e_Link:
                    $link = new Link($annot);
                    $action = $link->GetAction();
                    if (!$action->IsValid()) {
                        continue;
                    }
                    if ($action->GetType() == Action::e_GoTo) {
                        $dest = $action->GetDest();
                        if (!$dest->IsValid()) {
                            echo nl2br("  Destination is not valid\n");
                        } else {
                            $page_n = $dest->GetPage()->GetIndex();
                            echo nl2br("  Links to: page number " . $page_n . " in this document\n");
                        }
                    } else {
                        if ($action->GetType() == Action::e_URI) {
                            $uri = $action->GetSDFObj()->Get("URI")->Value()->GetAsPDFText();
                            echo nl2br("  Links to: " . $uri . "\n");
                        }
                    }
                    // ...
                    break;
                case Annot::e_Widget:
                    break;
                case Annot::e_FileAttachment:
                    break;
                    // ...
                // ...
                default:
                    break;
            }
        }
    }
    // Use the high-level API to create new annotations.
    $first_page = $doc->GetPage(1);
    // Create a hyperlink...
    $hyperlink = Link::Create($doc->GetSDFDoc(), new Rect(85.0, 570.0, 503.0, 524.0), Action::CreateURI($doc->GetSDFDoc(), "http://www.pdftron.com"));
    $first_page->AnnotPushBack($hyperlink);
    // Create an intra-document link...
    $goto_page_3 = Action::CreateGoto(Destination::CreateFitH($doc->GetPage(3), 0));
    $link = Link::Create($doc->GetSDFDoc(), new Rect(85.0, 458.0, 503.0, 502.0), $goto_page_3);
    // Set the annotation border width to 3 points...
    $border_style = new BorderStyle(BorderStyle::e_solid, 3.0, 0.0, 0.0);
    $link->SetBorderStyle($border_style);
    $link->SetColor(new ColorPt(0.0, 0.0, 1.0));
    // Add the new annotation to the first page
    $first_page->AnnotPushBack($link);
    // Create a stamp annotation ...
    $stamp = RubberStamp::Create($doc->GetSDFDoc(), new Rect(30.0, 30.0, 300.0, 200.0));
    $stamp->SetIcon("Draft");
    $first_page->AnnotPushBack($stamp);
    // Create a file attachment annotation (embed the 'peppers.jpg').
    global $input_path;
    $file_attach = FileAttachment::Create($doc->GetSDFDoc(), new Rect(80.0, 280.0, 200.0, 320.0), $input_path . "peppers.jpg");
    $first_page->AnnotPushBack($file_attach);
    $ink = Ink::Create($doc->GetSDFDoc(), new Rect(110.0, 10.0, 300.0, 200.0));
    $pt3 = new Point(110.0, 10.0);
    $ink->SetPoint(0, 0, $pt3);
    $pt3->x = 150;
    $pt3->y = 50;
    $ink->SetPoint(0, 1, $pt3);
    $pt3->x = 190;
    $pt3->y = 60;
    $ink->SetPoint(0, 2, $pt3);
    $pt3->x = 180;
    $pt3->y = 90;
    $ink->SetPoint(1, 0, $pt3);
    $pt3->x = 190;
    $pt3->y = 95;
    $ink->SetPoint(1, 1, $pt3);
    $pt3->x = 200;
    $pt3->y = 100;
    $ink->SetPoint(1, 2, $pt3);
    $pt3->x = 166;
    $pt3->y = 86;
    $ink->SetPoint(2, 0, $pt3);
    $pt3->x = 196;
    $pt3->y = 96;
    $ink->SetPoint(2, 1, $pt3);
    $pt3->x = 221;
    $pt3->y = 121;
    $ink->SetPoint(2, 2, $pt3);
    $pt3->x = 288;
    $pt3->y = 188;
    $ink->SetPoint(2, 3, $pt3);
    $ink->SetColor(new ColorPt(0.0, 1.0, 1.0), 3);
    $first_page->AnnotPushBack($ink);
    //Create a Polygon annotation..
    //$poly2=Polygon::Create($doc->GetSDFDoc, new Rect(100.0, 60.0, 300.0, 480.0));
    //$pllp = new Point();
    //$pllp->x=105;
    //$pllp->y=68;
    //$poly2->SetVertex(0, $pllp);
    //$pllp->x=155;
    //$pllp->y=92;
    //$poly2->SetVertex(1, $pllp);
    //$pllp->x=189;
    //$pllp->y=133;
    //$poly2->SetVertex(2, $pllp);
    //$pllp->x=200;
    //$pllp->y=140;
    //$poly2->SetVertex(3, $pllp);
    //$pllp->x=230;
    //$pllp->y=389;
    //$poly2->SetVertex(4, $pllp);
    //$pllp->x=300;
    //$pllp->y=405;
    //$poly2->SetVertex(5, $pllp);
    //$poly2->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    //$poly2->SetInteriorColor(new ColorPt(1.0, 0.0, 0.0), 3);
    //$first_page->AnnotPushBack($poly2);
    // ...
}