# Zoom to mouse outside the document area/viewer

**URL:** <https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [July 30, 2024, 7:51am UTC](https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363 "2024-07-30T07:51:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev\_onehub](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@dev\_onehub](https://pdfjs.community/u/dev_onehub)\
**Post date:** [July 30, 2024, 7:51am UTC](https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363/1 "2024-07-30T07:51:32Z")

</div>

**Which product are you using?**  
PDF.js Express Plus

**PDF.js Express Version**  
8.6.0

**Detailed description of issue**  
Hi team,

Currently, if we zoom in outside the document, it will force zoom to the “center” of the document and then zoom to mouse after certain conditions.

Is there any example / API to **zoom to mouse** outside the document area?

I need this feature because sometimes we need to zoom in on the edge of the document.

Please see example video below compared with Bluebeam:

> **[Zoom on PDFJS and BB.mov](https://drive.google.com/file/d/1X14-Wm2dBixaSLfRYwEaFElBYQpxceuN/view?usp=sharing)**
>
> Google Drive file.

Thanks

**Expected behaviour**  
Can zoom freely according to the direction of the pointer even in outside of the doc area.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [July 30, 2024, 4:47pm UTC](https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363/3 "2024-07-30T16:47:47Z")

</div>

Hi there,

To zoom to mouse, please use the documentViewer.zoomToMouse API:  
[PDFJS Express WebViewer Class: DocumentViewer](https://pdfjs.express/api/Core.DocumentViewer.html#zoomToMouse__anchor:~:text=to%20scroll%20to.-,zoomToMouse,-)(zoom%2C%20offsetX%2C%20offsetY

best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![dev\_onehub](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@dev\_onehub](https://pdfjs.community/u/dev_onehub)\
**Post date:** [July 31, 2024, 10:28am UTC](https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363/4 "2024-07-31T10:28:24Z")

</div>

Hi @kkim

Thanks for the response. Yes, I use that API but it has not been successful yet.

How about the ability to drag and move (pan) the document on the “unlimited-size” of viewer boundary?

example:

> **[BB page move.mov](https://drive.google.com/file/d/10PMSA-mG8hDqXK4qSo9kf58AAE1HQ7qd/view?usp=sharing)**
>
> Google Drive file.

Can this be achieved using custom DisplayMode?

Thanks

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [July 31, 2024, 7:13pm UTC](https://pdfjs.community/t/zoom-to-mouse-outside-the-document-area-viewer/3363/5 "2024-07-31T19:13:17Z")

</div>

Hi there,

The available APIs for the custom display modes are here:  
[https://pdfjs.express/api/Core.DisplayMode.html#setCustomFunctions\_\_anchor](https://pdfjs.express/api/Core.DisplayMode.html#setCustomFunctions__anchor)

We don’t have an API to set the document on the ‘unlimited size’ view.

If you zoom out of the document and then use the pan tool, you can scroll up or down but not in side ways because the document is ‘centred’

Best regards,  
Kevin Kim
