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

More
IP: 192.168.0.71 8 years 3 months ago - 8 years 3 months ago #13087 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
Last edit: 8 years 3 months ago by highc0d3r.
More
IP: 192.168.0.71 8 years 3 months ago - 8 years 3 months ago #13091 by nermeen
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:
Code:
PDFPAge.ObjsGetCharIndex
to get the char index at x,y in PDF coordinates
Code:
PDFPage.AddAnnotMarkup
to recreated the highlight annotation

If you have a premium license you can use:
Code:
PDFAnnot.Export
to export an annot
Code:
PDFPage.ImportAnnot
to import an annot.

If what you want is something different, please explain with details.
Last edit: 8 years 3 months ago by nermeen.
More
IP: 192.168.0.71 8 years 3 months ago #13095 by highc0d3r
how to get the x,y co-ordinates and pass it to the PDFPAge.ObjsGetCharIndex() to get start index and end index ?
More
IP: 192.168.0.71 8 years 3 months ago #13099 by nermeen
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
Code:
PDFVPage.ToPDFX, ToPDFY
like in PDFVPage.SetSel the char index is calculated in PDFVSel.SetSel
In the demo project it works based on the following scenario:
  1. Click on the highlight button, which starts the selection mode
    Code:
    m_view.vSelStart();
  2. Handle the selection based on touch events: PDFView.OnSelTouchBegin, OnSelTouchMove, OnSelTouchEnd
  3. Show the selection handling dialog
  4. End selection mode
    Code:
    m_view.vSelEnd();
Time to create page: 0.388 seconds
Powered by Kunena Forum