PDFJS Express Zoom API

Zoom API not working…

Please for code snippet using the zoom API from PDFJS express!

Using the code below, the zoom API of DocumentViewer does not response…

var instance = getInstance(document.getElementById(1));
var docViewer = instance.Core.documentViewer;
var zoomLevel = instance.Core.documentViewer.getZoom();
docViewer.setCurrentPage(1);
docViewer.setPageZoom(1, (zoomLevel * 2));
//docViewer.updateVisiblePages( ); // ???

Thanks for help.
C.Sonnweber

Hey there!

I just tried your code and it worked exactly as expected.

Make sure you are calling the code in the documentLoaded event like so:

instance.Core.documentViewer.addEventListener('documentLoaded', () => {
    const docViewer = instance.Core.documentViewer;
    const zoomLevel = instance.Core.documentViewer.getZoom();
    docViewer.setCurrentPage(1);
    docViewer.setPageZoom(1, (zoomLevel * 2));
  })

Thanks!
Logan

Hi Logan, thanks for reply.
We don’t not use the internal header-items of pdfjs express. We are invoking only few pdfjs-function by external buttons. See screenshot attached. It explains the scenario…The header items I have disabled.
Your code just explains setting the zoom a inside the documentLoaded event…
We click the zoom buttons until desired magnification of picture…

Thanks,
Christian