Create Annotation on Righ click of web document viewer

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
jwalit.katira
Posts: 31
Joined: Mon Sep 18, 2023 1:41 pm

Create Annotation on Righ click of web document viewer

Post by jwalit.katira »

Hello,

I have created annotation on contextmenu_showing method but the annotation in not proper placed in same location where mouse is right clicked , I have also used imageViewer.transformPointFromScreenToControl method , it is working in some tiff file but not working in all tiff and PDF files, it shows wrong position

Below is my code

Code: Select all

 function __annotationContextMenu_showing(event, eventArgs) {
      // get the document viewer
      var docViewer = this.get_RootControl();
      // if document viewer exists
      if (docViewer != null) {
        var position = eventArgs.position;
        var viewer = docViewer.get_ImageViewer();
        var annotationVisualTool = viewer.get_AnnotationVisualTool();

        let newposisiton = imageViewer.transformPointFromScreenToControl(
          position.x,
          position.y
        );


        let imageAnnotation =
          new Vintasoft.Imaging.Annotation.UI.WebReferencedImageAnnotationViewJS();
        imageAnnotation.set_Url("https://demos.vintasoft.com/AspNetCoreDocumentViewerDemo/Images/VintaSoftLogo.png")

          imageAnnotation.set_Location(newposisiton.x, newposisiton.y);

        imageAnnotation.set_Size(25, 25);
        imageAnnotation.set_Border(false);
        imageAnnotation.set_CanResize(false);
        imageAnnotation.set_CanRotate(false);

        imageViewer.addAndBuildAnnotation(imageAnnotation);

        // set annotation under mouse cursor as focused annotation
        AnnotationVisualTool.set_FocusedAnnotationView(imageAnnotation);
Thanks
Jwalit Katira
Alex
Site Admin
Posts: 2319
Joined: Thu Jul 10, 2008 2:21 pm

Re: Create Annotation on Righ click of web document viewer

Post by Alex »

Hello Jwalit,

The WebAnnotationViewJS.set_Location function (https://www.vintasoft.com/docs/vsimagin ... ation.html) sets the annotation location, in device-independent units (1/96th inch per unit).

Please transfer point from the control space to the annotation space (1/96th inch per unit) using the WebAnnotationViewerJS.transformPointFromControlToDip function (https://www.vintasoft.com/docs/vsimagin ... ToDip.html).

Also please remember that the location of WebReferencedImageAnnotationViewJS object is located in the center of image annotation.

Best regards, Alexander
jwalit.katira
Posts: 31
Joined: Mon Sep 18, 2023 1:41 pm

Re: Create Annotation on Righ click of web document viewer

Post by jwalit.katira »

Thanks Alex , it is working
Post Reply