Set default zoom level for all documents

4,006 views
Skip to first unread message

Glen Davies

unread,
Jan 30, 2018, 4:43:07 PM1/30/18
to PDFTron WebViewer
Hi

Is there still now way to set the default zoom level for all docs? ie. if zoom level is set to 0.5 for one document, when another document is loaded it goes back to fit to page. We can get around this with 

$(document).on('documentLoaded', function () {
    readerControl.setZoomLevel(0.5);
})

but there is a bit of a flicker, particularly if zoom varies widely from default and scrolls bars flicker in and out. It would be good if there was a way to set and reset the default zoom level for the reader independent of the document loads.

Thanks
Glen

Matt Parizeau

unread,
Jan 31, 2018, 2:15:05 PM1/31/18
to PDFTron WebViewer
Hi Glen,

You can use the "defaults" value on DocumentViewer which will be used when a new document is loaded in the same viewer. Note that you'll also likely want to set the default fit mode because if the default fit mode isn't set to docViewer.FitMode.Zoom then it will stay at the initially set default fit mode.

$(document).on('viewerLoaded', function() {
  readerControl
.docViewer.on('zoomUpdated', function(e, zoom) {
    readerControl
.docViewer.defaults.Zoom = zoom;
 
});

  readerControl
.docViewer.on('fitModeUpdated', function(e, fitMode) {
    readerControl
.docViewer.defaults.FitMode = fitMode;
 
});
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Glen Davies

unread,
Feb 1, 2018, 12:47:44 PM2/1/18
to PDFTron WebViewer
Excellent - thanks for the quick response.
Reply all
Reply to author
Forward
0 new messages