Adding a Link Programmatically with WebViewer

98 views
Skip to first unread message

Matt Parizeau

unread,
Feb 17, 2014, 3:04:31 PM2/17/14
to
Q:

Can webviewer do link annotations?  Would it just be like adding a link annotation with the normal SDK?

A:

Here is some sample code to add external or internal links.  Note that this only works with WebViewer 1.7 and higher and only with documents converted with PDFNet 6.0 or higher (that have an internal XFDF document).

var doc = docViewer.GetDocument();
var pageIndex = 0;
var point1 = doc.GetPDFCoordinates(pageIndex, 0, 0);
var point2 = doc.GetPDFCoordinates(pageIndex, 100, 100);

var pageLinks = doc.GetLinks(pageIndex);

// creates an external link
var externalLink = new CoreControls.Hyperlink([point1.x, point1.y, point2.x, point2.y], "http://www.pdftron.com");
pageLinks
.push(externalLink);
// creates an internal link to page 5 in the document with offset (0, 0)
var internalLink = new CoreControls.Link([point1.x, point1.y, point2.x, point2.y], 5, 0, 0);
pageLinks
.push(internalLink);

docViewer
.UpdateView();

Reply all
Reply to author
Forward
0 new messages