Forum 'VintaSoft Annotation .NET Plug-in Discussions'

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

Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions

Login

Create Annotation on Righ click of web document viewer



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
 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


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


Re: Create Annotation on Righ click of web document viewer

Post by jwalit.katira »

Thanks Alex , it is working


Page 1 from 1: 1