pdfviewr and position mouse


Is there a component in pdfviewr that allows adding an image at a position selected by the mouse? If I can recover the position X, Y, Z it would be enough.

3 Replies

VS Vikas Sekar Syncfusion Team July 31, 2020 08:08 PM UTC

Hi Matthew,  
  
Thanks for contacting Syncfusion support.  
  
In PdfViewerControl by using PageClicked event we can get the current clicked position and page index of the PDF page. Please find the code snippet below to use the PageClicked event. 
 
#region Constructor 
public Form1() 
{ 
       InitializeComponent(); 
       //Load the PDF file. 
       pdfViewerControl1.Load("../../Data/HTTP Succinctly.pdf"); 
 
       //Wire the `PageClicked` event. 
       pdfViewerControl1.PageClicked += PdfViewer_PageClicked; 
} 
#endregion 
                              
#region Event 
void PdfViewer_PageClicked(object sender, PageClickedEventArgs args) 
{ 
       //Find the page number in which the mouse clicks occurred. 
       int currentPage = args.PageIndex; 
 
       //Find the mouse position on above the document page 
       System.Drawing.PointF mousePosition = args.Position; 
} 
 #endregion 
 
  
 
Currently, we are analyzing to add an image at a given position in PDFpages. We will update you with further details on 4th Aug, 2020.  
 
Regards,  
Vikas  



RO Rogério replied to Vikas Sekar August 1, 2020 12:31 AM UTC

Hi Matthew,  
  
Thanks for contacting Syncfusion support.  
  
In PdfViewerControl by using PageClicked event we can get the current clicked position and page index of the PDF page. Please find the code snippet below to use the PageClicked event. 
 
#region Constructor 
public Form1() 
{ 
       InitializeComponent(); 
       //Load the PDF file. 
       pdfViewerControl1.Load("../../Data/HTTP Succinctly.pdf"); 
 
       //Wire the `PageClicked` event. 
       pdfViewerControl1.PageClicked += PdfViewer_PageClicked; 
} 
#endregion 
                              
#region Event 
void PdfViewer_PageClicked(object sender, PageClickedEventArgs args) 
{ 
       //Find the page number in which the mouse clicks occurred. 
       int currentPage = args.PageIndex; 
 
       //Find the mouse position on above the document page 
       System.Drawing.PointF mousePosition = args.Position; 
} 
 #endregion 
 
  
 
Currently, we are analyzing to add an image at a given position in PDFpages. We will update you with further details on 4th Aug, 2020.  
 
Regards,  
Vikas  


Hello again, 
thank you very much for the information above, I'm trying to get by with it. 
Looking in the forum I saw that you have something similar to what I imagined in 

https://www.syncfusion.com/blogs/post/draw-on-a-pdf-in-a-windows-app.aspx 

but I couldn't replicate in windows forms, is there any example?

Attachment: DrawonPDF_550_5d0b95f0.rar


DG Deepak Gunasekaran Syncfusion Team August 3, 2020 12:33 PM UTC

Hi Matthew, 
 
We do not have support for drawing free form (ink) annotation in Windows Forms as supported in the Windows Apps that you have shown us as a reference. However, this support was already provided in the WPF PDF Viewer and that can be hosted in WinForms application to achieve the requirement, please refer to the following links for more details. 
 
We have also modified the sample by setting the ink annotation mode as default and it can be downloaded from the following location: 
 
Kindly let us know if the above suggestion helps and let us know if you need any further assistance. 
 
Regards, 
Deepak G 


Loader.
Up arrow icon