CoreControls.Document.getViewerCoordinates() always errors

37 views
Skip to first unread message

fr

unread,
Oct 13, 2016, 7:54:03 PM10/13/16
to PDFTron WebViewer
Am I missing something with this function?
I can execute other functions on the document but not getViewerCoordinates.
I am using version 2.2.1

var viewerElement = document.getElementById("viewer");
var myWebViewer = new PDFTron.WebViewer({
path: "lib",
type: "html5",
initialDoc: "https://azure.blob/doc.xod",
azureWorkaround: true,
config: "config.js",
enableAnnotations: true
}, viewerElement);


$(document).on('documentLoaded', function () {
var docViewer = readerControl.docViewer;
var doc = docViewer.getDocument();
var num = doc.getPageCount(); // executes correctly
var coords = doc.getViewerCoordinates(1, x, y); // errors
}

I want to translate pdf coordinates into canvas coordinates I can use in annotation:draw

Matt Parizeau

unread,
Oct 19, 2016, 1:43:49 PM10/19/16
to PDFTron WebViewer
Hi,

How many pages does your document have? Note that getViewerCoordinates expects a zero-indexed value for the first parameter (http://www.pdftron.com/webviewer/demo/lib/html5/doc/symbols/CoreControls.Document.html#getViewerCoordinates)
So if your document only has one page then that code won't work and you'll want to pass a 0 instead of a 1.

Let me know if that helps!

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