- Posts: 3
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
Highlighting text based on x and y co-ordinates
IP: 192.168.0.71
8 years 3 months ago - 8 years 3 months ago #13087
by highc0d3r
Highlighting text based on x and y co-ordinates was created by highc0d3r
Hi,
We are working on a pdf viewer where we have to highlight text based on x and y axis. We are saving the x and y co-ordinates to local storage and when ever the user loads the pdf based on the x and y point we want to perform the highlight. of that text. Is there any way to do that ? If so please share us a sample code so that we can perform the highlight
Thanks
We are working on a pdf viewer where we have to highlight text based on x and y axis. We are saving the x and y co-ordinates to local storage and when ever the user loads the pdf based on the x and y point we want to perform the highlight. of that text. Is there any way to do that ? If so please share us a sample code so that we can perform the highlight
Thanks
Last edit: 8 years 3 months ago by highc0d3r.
IP: 192.168.0.71
8 years 3 months ago - 8 years 3 months ago #13091
by nermeen
Replied by nermeen on topic Highlighting text based on x and y co-ordinates
The most straightforward way, is to save the highlight annotation start and end char indices in PDF coordinates, and then reuse it to recreated the highlight.
You can use:
to get the char index at x,y in PDF coordinates
to recreated the highlight annotation
If you have a premium license you can use:
to export an annot
to import an annot.
If what you want is something different, please explain with details.
You can use:
Code:
PDFPAge.ObjsGetCharIndex
Code:
PDFPage.AddAnnotMarkup
If you have a premium license you can use:
Code:
PDFAnnot.Export
Code:
PDFPage.ImportAnnot
If what you want is something different, please explain with details.
Last edit: 8 years 3 months ago by nermeen.
IP: 192.168.0.71
8 years 3 months ago #13095
by highc0d3r
Replied by highc0d3r on topic Highlighting text based on x and y co-ordinates
how to get the x,y co-ordinates and pass it to the PDFPAge.ObjsGetCharIndex() to get start index and end index ?
IP: 192.168.0.71
8 years 3 months ago #13099
by nermeen
Replied by nermeen on topic Highlighting text based on x and y co-ordinates
It depends on how you want to implement it, if it's based on the touch event, then x,y will be the touch point,
You only need to convert screen coordinates to PDF coordinates, using
like in PDFVPage.SetSel the char index is calculated in PDFVSel.SetSel
In the demo project it works based on the following scenario:
You only need to convert screen coordinates to PDF coordinates, using
Code:
PDFVPage.ToPDFX, ToPDFY
In the demo project it works based on the following scenario:
- Click on the highlight button, which starts the selection mode
Code:m_view.vSelStart();
- Handle the selection based on touch events: PDFView.OnSelTouchBegin, OnSelTouchMove, OnSelTouchEnd
- Show the selection handling dialog
- End selection mode
Code:m_view.vSelEnd();
Time to create page: 0.388 seconds