How can I programmatically create replies to annotations?

21 views
Skip to first unread message

Shakthi Wijeratne

unread,
Mar 26, 2020, 5:02:01 PM3/26/20
to PDFTron PDFNet SDK
A: You can create replies to markup annotations programmatically in your application by using the following code (C++):

    PDFDoc doc("input.pdf"); // input doc
    Page pg = doc.GetPage(x); // page the annotation is on
    Annot parent = pg.GetAnnot(y); // The annotation that the user will reply to

    Rect rect = parent.GetRect();
    rect.Normalize();

    double left = rect.GetX1();
    double top = rect.GetY2();

    Point p(left, top);
    PDF::Annots::Text reply = PDF::Annots::Text::Create(doc, p);
    reply.SetTitle("AUTHOR"); // this function is used to set the author/user of the reply
    reply.GetSDFObj().Put("IRT", parent.GetSDFObj());
    Rect popuprect;
    popuprect.Set(left + 20, top + 20, left + 90, top + 90);
    PDF::Annots::Popup popup = PDF::Annots::Popup::Create(doc, popuprect);
    popup.SetParent(reply);
    popup.SetContents("Comment that the person made"); // the users comment goes here
    reply.SetPopup(popup);
    pg.AnnotPushBack(reply);
Reply all
Reply to author
Forward
0 new messages