Navigate to annotation programatically

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}

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

Best regards,
Kevin Kim

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

Hi there,

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

Best regards,
Kevin Kim

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