I get an exception trying to access the annotationManager

22 views
Skip to first unread message

Ryan - PDFNet Developer

unread,
Sep 20, 2016, 8:03:47 PM9/20/16
to PDFTron WebViewer
Question:

CoreControls.AnnotationManager contains hideAnnotation(annot) and showAnnotation(annot) functions.

But when I try to access these functions from my custom javascript function its throwing exception as function not found.

Answer:

The exact javascript code needed depends first on where you are calling from. If your code resides inside the config.js file, that you pass into the WebViewer constructor, then the following should work.


var am = readerControl.docViewer.GetAnnotationManager();
annotation
= am.getAnnotationById(previousHighlightKey);
if(annotation !=null)
{
 am
.HideAnnotation(annotation);  // or am.hideAnnotation(annotation);

}

If you are calling from your HTML side, then it would be the following.

var am = myWebViewer.getInstance().docViewer.GetAnnotationManager(); // where myWebViewer is the default variable name for the WebViewer instance in the sample HTML files.
annotation
= am.getAnnotationById(previousHighlightKey);
if(annotation !=null)
{
 am
.HideAnnotation(annotation);  // or am.hideAnnotation(annotation);

}

Reply all
Reply to author
Forward
0 new messages