Cannot get correct bounding rectangle for Sticky Annotation

47 views
Skip to first unread message

Dhaya Benmessaoud

unread,
May 9, 2017, 12:01:05 PM5/9/17
to PDFTron WebViewer
Hi,

I'm trying to get the correct dimensions (x, y, width, height) of the annotations in order to position my custom annotation edition dialogs.
By using what's inside AnnotationEdit.js as a reference, I've been mostly successful, except for the StickyAnnotation, which gives me a box that is roughly 2 times bigger.

Here is the code I use in order to get the bounding rectangle :

get rect() {
    const offset = { top: $scrollView.scrollTop(), left: $scrollView.scrollLeft() };
    const topLeft = displayMode.pageToWindow({ x: annotation.X, y: annotation.Y }, annotation.PageNumber - 1);
    const bottomRight = displayMode.pageToWindow({ x: annotation.X + annotation.Width, y: annotation.Y + annotation.Height }, annotation.PageNumber - 1);

    return {
        x: topLeft.x,
        y: topLeft.y - offset.top,
        width: bottomRight.x - topLeft.x,
        height: (bottomRight.y - offset.top) - (topLeft.y - offset.top),
    };
},

And here is a debug output of what's computed.



Am I missing something?


Best regards,
Dhaya
annotations-rects.png

Justin Jung

unread,
May 9, 2017, 4:16:08 PM5/9/17
to PDFTron WebViewer on behalf of Dhaya Benmessaoud
Hello Dhaya,

StickyNotes have NoZoom property set to true. You can check annotation.NoZoom property and if this is true, you can divide the width and height by the current zoom level (docViewer.getPageZoom(annotation.PageNumber - 1)).

Justin Jung
Software Developer
PDFTron Systems Inc.

Dhaya Benmessaoud

unread,
May 10, 2017, 1:10:13 PM5/10/17
to PDFTron WebViewer
Great, thanks!
Reply all
Reply to author
Forward
0 new messages