Default scroll position of newly loaded & zoomed PDF?

Hello!

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:

<script>
  WebViewer({
    path: 'PDF/lib', 
    licenseKey: 'xxxxxxxxxxxxxxx',
    disabledElements: [
    'leftPanelButton','searchPanel','selectToolButton','searchButton','viewControlsButton','marqueeToolButton','themeChangeButton','contextMenuPopup'
    ],
    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;
    instance.UI.setLanguage('hu');

    // 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) %>);
    })
  });
</script>

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:

Guides:APIs:Forums:

Hey!

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.

Thanks,
Logan