Page 1 of 1

how to get left,top,width and height when add annotation in server side

Posted: Wed Jun 07, 2023 5:42 am
by senthil205
Hi sir,
we already purchase viewer

I need to get the left, top, width and height when add the annotation in viewer to store in DB after close and view the sample in need to show annotation as we add the annotation at what position.

Now i get all properties except left, top, width, height i give hardcode the height,width,left,top so please assists us.

Re: how to get left,top,width and height when add annotation in server side

Posted: Mon Jun 12, 2023 6:01 pm
by Fabio
Hello,

Here is a code snippet to get the coordinates of an annotation when it has been drawn in the viewer:

Code: Select all

function RegisterOnAnnotationAddedOnDocuViewareAPIReady() { 
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) { 
        DocuViewareAPI.RegisterOnAnnotationAdded("DocuVieware1", function (annot) { 
            var myAnnot = DocuViewareAPI.GetAnnotProperties("DocuVieware1", annot.id); 
            console.log("top: " + myAnnot.top); 
            console.log("left: " + myAnnot.left); 
            console.log("width: " + myAnnot.width); 
            console.log("height: " + myAnnot.height); 
         }); 
    } 
    else { 
        setTimeout(function () { RegisterOnAnnotationAddedOnDocuViewareAPIReady() }, 10); 
    } 
} 
document.addEventListener("DOMContentLoaded", function () { 
    RegisterOnAnnotationAddedOnDocuViewareAPIReady(); 
}, false);
Best regards,
Fabio