Annotation is not editable after being imported from another document.

17 views
Skip to first unread message

Ryan

unread,
Feb 4, 2016, 1:31:47 PM2/4/16
to PDFTron PDFNet SDK
Question:

After we import an annotation from another document, and position it, the annotation is not editable.

Answer:

The following code is the proper way to import and re-position (using Annot.Resize) an annotation onto the target page

PDFDoc source("path_to_source_pdf");
source
.InitSecurityHandler();
pdfviewctrl
->DocLock(true); // if viewing the target document, lock it first
PDFDoc* target = pdfviewctrl->GetDoc();
Obj* src_annot = source.GetPage(1).GetAnnot(0);
SDFDoc* sd = target->GetSDFDoc();
src_annot
->Erase("P"); // erase reference to source page, to prevent importing more than what is needed
Obj* dest_annot = sd->ImportObj(src_annot, true);
Annot new_annot(dest_annot);
target
->GetPage(1).AnnotPushBack(new_annot);
// calculate new position on target page
new_annot
.Resize(new_rect_position); // Important!
pdfviewctrl
->DocUnlock(); // unlock
pdfviewctrl
->Update(new_annot, 1); // refresh page





Reply all
Reply to author
Forward
0 new messages