Default scroll position of newly loaded & zoomed PDF?


Using PDF.js Express Viewer, I need the opened PDF-s be zoomed in at a certain area of the first page. Can it be done?

I figured out how a newly loaded document appears zoomed. But I cannot figure out how to scroll to a certain part of the page.

(Short explanation: we display old newspaper pages, but users are only interested in certain articles on the pages.)

My code:

    path: 'PDF/lib', 
    licenseKey: 'xxxxxxxxxxxxxxx',
    disabledElements: [
    initialDoc: 'mypdf.pdf',
    // initialDoc: '/path/to/my/file.pdf',  // You can also use documents on your server
  }, document.getElementById('viewer'))
  .then(instance => {
    // now you can access APIs through the WebViewer instance
    const { Core, UI } = instance;

    // adding an event listener for when a document is loaded
    Core.documentViewer.addEventListener('documentLoaded', () => {
      console.log('document loaded');
      instance.setZoomLevel(<% =Left(myzoomlevel, 1) & "." & Right(myzoomlevel, 2) %>);

Thank you in advance!

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:



What you are looking for is the zoomTo API - it lets you set the zoom level as well as the scroll position.

For example instance.Core.documentViewer.zoomTo(4, 60, 30) would zoom to 400% and scroll to 60,30.