how does zoomto works?

129 views
Skip to first unread message

Roxan Guingao

unread,
Jul 10, 2015, 12:59:39 PM7/10/15
to pdfnet-w...@googlegroups.com
Hi,

Im trying to zoom to a certain coordinate x and y, but its not viewing on the correct coordinate but its zooming.

readerControl.docViewer.zoomTo(8,xCoordinate,yCoordinate);

- Do I need to execute still scrollTop and scrollLeft on the jquery api to view?

Based on documentation zoomTo( ) means:

Adjusts the viewer's zoom factor, and positions the point (x,y) at the upper left corner of the viewer. Only renders if a document has been loaded.   

- Can you show me how to make this work?
    

Matt Bojey

unread,
Jul 10, 2015, 4:08:32 PM7/10/15
to pdfnet-w...@googlegroups.com
Hi,

The zoomTo function needs to take the coordinates as they will be represented at the new zoom level.  For example, if you wanted to zoom to the middle of the first page you could use:

 var pageInfo = readerControl.docViewer.getDocument().getPageInfo(0);
 
var xCoord = pageInfo.width / 2;
 
var yCoord = pageInfo.height / 2;
 readerControl
.docViewer.zoomTo(8, xCoord * 8, yCoord * 8);

Roxan Guingao

unread,
Jul 13, 2015, 12:41:33 PM7/13/15
to pdfnet-w...@googlegroups.com
Hi Matt,

This is how I made my events:

readerControl.docViewer.on('mouseLeftUp',function(event,mClick){

readerControl.docViewer.zoomTo(8,mClick.clientX * 8,mClick.clientY * 8);

}

The problem is its not zooming to the correct coordinates on the mouse click.

Matt Bojey

unread,
Jul 14, 2015, 8:36:41 PM7/14/15
to pdfnet-w...@googlegroups.com
Hi,

We have been working on new functionality that would be helpful to you, here is a custom build of WebViewer that add a zoomToMouse function:



You can use it like this:

$(document).on('documentLoaded', function(){
   
var docViewer = readerControl.docViewer;
    docViewer
.on('mouseLeftUp',function(){
       
var toolbarOffset = $('#control').outerHeight();
       
var sidePanelWidth = readerControl.sidePanelVisible() ? $('#sidePanel').width() : 0;
        docViewer
.zoomToMouse(8, sidePanelWidth, toolbarOffset);
   
});
});

Reply all
Reply to author
Forward
0 new messages