Page 1 of 1

Create Annotation on Righ click of web document viewer

Posted: Mon Sep 18, 2023 2:07 pm
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

Re: Create Annotation on Righ click of web document viewer

Posted: Wed Sep 20, 2023 2:52 pm
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

Posted: Fri Sep 22, 2023 2:04 pm
by jwalit.katira
Thanks Alex , it is working