Custom Annotation drop location on different Resolution

PDF.js Express Version

  1. Build: “Ni8yOS8yMDIwfDZhZDkzMGE=”
  2. Core version: “6.3.4”
  3. Full API: false
  4. UI version: “6.3.3”
  5. WebViewer Server: false

Detailed description of issue
I’ve showing PDFJs into Modal Component where we will set the our Custom annotation controls to our Pdf document but the problem is that when we check on different resolution its drop point location have changed.

Expected behaviour
Drop annotation point should be the same.

Does your issue happen with every document, or just one?
Every document

Code snippet
dropPoint ={};
instance.iframeWindow.document.body.ondrop = (e) => {
const scrollElement = instance.docViewer.getScrollViewElement();
const scrollLeft = scrollElement.scrollLeft || 0;
const scrollTop = scrollElement.scrollTop || 0;
this.dropPoint = { x: e.pageX + scrollLeft, y: e.pageY + scrollTop };


      return false;

let point = this.dropPoint || { x: layerX, y: layerY };
const { Annotations, docViewer, annotManager } = instanceRef;
const pageNumber = docViewer.getCurrentPage();
const freeText = new Annotations.FreeTextAnnotation();
freeText.PageNumber = pageNumber;
freeText.X = point.x;
freeText.Y = point.y;


Hello, I’m an automated tech support bot.

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Hey there,

Please see this guide about how PDF co-ordinates work. There is also some APIs in there should should help you normalize your values. This guide is a PDFTron guide, but it applies to PDF.js Express as well.

Let me know if you need any additional assistance.


I’m unable to run this line
const page = displayMode.getSelectedPages(windowCoordinates, windowCoordinates);

when above line execute its response first = 0 , last = 0;

any solution

here is my code

@Logan as you can see i’m unable to get the page number can you please assist me on this.

Hey there,

It looks like getSelectedPages returns a pageIndex and not a pageNumber, so you can just add one to page.first to get the page number