# Navigate to annotation programatically

**URL:** <https://pdfjs.community/t/navigate-to-annotation-programatically/3100>\
**Category:** Technical Support\
**Created:** [January 23, 2024, 12:21pm UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100 "2024-01-23T12:21:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![neeraj.khosla](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@neeraj.khosla](https://pdfjs.community/u/neeraj.khosla)\
**Post date:** [January 23, 2024, 12:21pm UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100/1 "2024-01-23T12:21:40Z")

</div>

**Which product are you using?**

**PDF.js Express Version**

**Detailed description of issue**  
I am adding multiple annotations to the PDF dynamically. The screen is divided into 2 parts. left part contains an HTML table containing annotation ids in it. The right part contains the pdf. If a user clicks on any annotation id in HTML table, the pdf view will scroll to that annotation in right section. So, its a kind of navigation for annotations.

Here’s what I am trying to do.

1. Using annotationManager, I tried to find the annotation.
2. Get X and Y of annotation.
3. Translate that to webviewer coordinates using doc.getViewerCoordinates.
4. Using scrollTo function to scroll to those coordinates.

This is working up to some extent, but when there is a Zoom, it does not work as expected. Can you please help me to write correct logic ?

**Expected behaviour**  
Need to navigate to annotation so that it can be shown to the user. If the annotation is on 2nd page, then the view will scroll to 2nd page to that annotation and it will be visible to the user.

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
{Provide a relevant code snippet}

---

<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:** [January 23, 2024, 6:30pm UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100/2 "2024-01-23T18:30:49Z")

</div>

Hi there,

Thank you for contacting pdf.js express forums,

It looks like you would want to use the jumpToAnnotation API:  
[https://pdfjs.express/api/Core.AnnotationManager.html#jumpToAnnotation\_\_anchor](https://pdfjs.express/api/Core.AnnotationManager.html#jumpToAnnotation__anchor)

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![neeraj.khosla](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@neeraj.khosla](https://pdfjs.community/u/neeraj.khosla)\
**Post date:** [January 24, 2024, 5:08am UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100/3 "2024-01-24T05:08:31Z")

</div>

Can you please provide a working example code for this ? I tried to use it, but its giving error to me.

---

<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:** [January 24, 2024, 3:06pm UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100/4 "2024-01-24T15:06:05Z")

</div>

Hi there,

Could you please share the error message / screenshot and the code snippet you tried to use?

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![neeraj.khosla](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@neeraj.khosla](https://pdfjs.community/u/neeraj.khosla)\
**Post date:** [January 25, 2024, 6:26am UTC](https://pdfjs.community/t/navigate-to-annotation-programatically/3100/5 "2024-01-25T06:26:03Z")

</div>

I got it working. Thanks for your help. I was not getting the annotation in a correct way.
