Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
  • Page:
  • 1

TOPIC:

Highlighting text based on x and y co-ordinates 6 years 5 months ago #13087

  • highc0d3r
  • highc0d3r's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Last edit: by highc0d3r.

Highlighting text based on x and y co-ordinates 6 years 5 months ago #13091

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
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:
PDFPAge.ObjsGetCharIndex
to get the char index at x,y in PDF coordinates
PDFPage.AddAnnotMarkup
to recreated the highlight annotation

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

If what you want is something different, please explain with details.

Please Log in or Create an account to join the conversation.

Last edit: by nermeen.

Highlighting text based on x and y co-ordinates 6 years 5 months ago #13095

  • highc0d3r
  • highc0d3r's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
how to get the x,y co-ordinates and pass it to the PDFPAge.ObjsGetCharIndex() to get start index and end index ?

Please Log in or Create an account to join the conversation.

Highlighting text based on x and y co-ordinates 6 years 5 months ago #13099

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
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
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
    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
    m_view.vSelEnd();

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum