# PDFJS Express Zoom API

**URL:** <https://pdfjs.community/t/pdfjs-express-zoom-api/1354>\
**Category:** Bug Reports\
**Created:** [February 8, 2022, 3:53pm UTC](https://pdfjs.community/t/pdfjs-express-zoom-api/1354 "2022-02-08T15:53:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user68](https://avatars.discourse-cdn.com/v4/letter/u/53a042/32.png) [@user68](https://pdfjs.community/u/user68)\
**Post date:** [February 8, 2022, 3:53pm UTC](https://pdfjs.community/t/pdfjs-express-zoom-api/1354/1 "2022-02-08T15:53:25Z")

</div>

Zoom API not working…

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

 ![grafik](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/0d7021fdf19ad25d186642fd7bbc29052ec1bca7.png)

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](https://docViewer.updateVisiblePages)( ); // ???_

Thanks for help.  
C.Sonnweber

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [February 9, 2022, 6:02pm UTC](https://pdfjs.community/t/pdfjs-express-zoom-api/1354/3 "2022-02-09T18:02:14Z")

</div>

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:

```javascript
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

---

<div class="post-metadata">

**Author:** ![user68](https://avatars.discourse-cdn.com/v4/letter/u/53a042/32.png) [@user68](https://pdfjs.community/u/user68)\
**Post date:** [February 9, 2022, 9:23pm UTC](https://pdfjs.community/t/pdfjs-express-zoom-api/1354/4 "2022-02-09T21:23:23Z")

</div>

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…

 ![grafik](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/0a53019d45b3afe1b3a0cb9cf720b6a506ff73ac.jpeg)

Thanks,  
Christian
