Navigation to the annotation position in WebViewer

66 views
Skip to first unread message

MoxFulder

unread,
Dec 5, 2014, 1:28:18 PM12/5/14
to pdfnet-w...@googlegroups.com
Hello, I need to open document in WebViewer in a position, where some annotation is. Such as when we click one annotation on Annotation Panel and viewer go to a page and position of selected annotation.
I found, how to jump to some page with .setCurrentPageNumber(), but it show upper part of a page and annotation may lie outside visible area.

Matt Parizeau

unread,
Dec 5, 2014, 5:52:48 PM12/5/14
to
Hi,

To do this you would want to use a config file with a bit of custom code. A config file is just a JavaScript file that is executed in the context of the viewer. You can add it by passing the config option to the PDFTron.WebViewer constructor (see WebViewer samples for an example of this).

This sample code jumps to the location of the first annotation using the JumpToAnnotation function and you would put it in your config file:
$(document).on('documentLoaded', function() {
    var annotManager = readerControl.docViewer.GetAnnotationManager();
    var annot = annotManager.GetAnnotationsList()[0];

    annotManager
.JumpToAnnotation(annot);
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages