on a form I have a pdfviewer and I need to know where the user click on my pdf. The coordinates should be relative to the document not the all radpdfviewer area.
When I get the coordinate with iTextSharp I'll put some image on that area (this part I'm already able to do it)
Those are the possibilities that I thought:
- Select an area on pdfviewer and get the coordinates? (THIS ONE WOULD BE THE BEST)
- get the text selection position (I took a look to the documentation but I'm not able do reproduce the example.. this.PdfViewer.Document.CaretPosition is missing)
Any other idea?
5 Answers, 1 is accepted
We have a demo demonstrating a similar scenario using RadPdfViewer in combination with RadPdfProcessing. RadPdfViewer is used to visualize a PDF file and when the user clicks on it, the page index and location are obtained through the GetLocationFromViewPoint() method. The document is modified using the API of RadPdfProcessing, exported and opened. Please, find the sample project in the attachments.
However, if you prefer to stick to the approach with selection, you could check our help article that describes how you could create a TextSelection. After you have already selected the text, you could use the GetSelectionGeometry() method of the Selection in order to check the start position of the geometry that describes the selection.
Hope this helps.
Hi. thank you Tanya for the reply.
I can't find the sample project.. can you reattach it, please?
Please, excuse me for this - it seems like something failed. The sample project should be attached to this post.
We have managed to reproduce the incorrect positioning when page Rotation value is different from Rotate0. We are attaching a modified version of the sample project showing how to position the FixedContentEditor so that the added image is positioned correctly on pages with different rotations. You may take a look at AdjustEditorPosition() method in order to see how exactly these calculations are performed. The modified demo uses sample document with different page sizes and page rotations - Rotate0, Rotate180, and Rotate270 respectively. You may test that all scenarios are working correctly by clicking on different document pages.
I hope this is helpful. If you have any other questions or concerns please do not hesitate to contact us again.
Telerik by Progress