how to get startIndex and endIndex of highlighted text in PDF - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about iOS development and PDF

TOPIC: how to get startIndex and endIndex of highlighted text in PDF

Get StartIndex and EndIndex of highlighted text 9 months 4 weeks ago #13166

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0
hi, how can i get startIndex and endIndex of highlighted text so that i can store in data base and again show the highlighted text in swift...
can any one suggest to get the start point and end point in page..
Thankyou.

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

how to get startIndex and endIndex of highlighted text in PDF 7 months 3 weeks ago #13397

  • josgou
  • josgou's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 8
  • Thank you received: 0
hi i want to store in my database start and end index of highlighted text so that i want to recreate the highlight..

public func onSelEnd(_ x1: Float, _ y1: Float, _ x2: Float, _ y2: Float) {
posx1 = Int(x1)
posy1 = Int(y1)
posx2 = Int(x2)
posy2 = Int(y2)

let m_scale = UIScreen.main.scale

let startIndex = pdfPage.objsGetCharIndex(Float(posx1 * Int(m_scale)), Float(posy1 * Int(m_scale)))
let endIndex = pdfPage.objsGetCharIndex(Float(posx2/Int(m_scale)), Float(posy2/Int(m_scale)))

but aim getting different location in pdf highlight can any one help me

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

Get StartIndex and EndIndex of highlighted text 7 months 3 weeks ago #13398

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0
public func onSelEnd(_ x1: Float, _ y1: Float, _ x2: Float, _ y2: Float) {
posx1 = Int(x1)
posy1 = Int(y1)
posx2 = Int(x2)
posy2 = Int(y2)

let m_scale = UIScreen.main.scale
let startIndex = pdfPage.objsGetCharIndex(Float(posx1 * Int(m_scale)), Float(posy1 * Int(m_scale)))
let endIndex = pdfPage.objsGetCharIndex(Float(posx2/Int(m_scale)), Float(posy2/Int(m_scale)))

but aim getting different location in pdf highlight can any one help me

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

Get StartIndex and EndIndex of highlighted text 7 months 3 weeks ago #13400

  • federico
  • federico's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 50
  • Thank you received: 4
Hi,
I suggest you to take a look in PDFView class at the OnSelTouchEnd method:
PDF_RECT rect = [vpage GetSelRect];
This method get the rect of the selected text in pdf's coordinates.
If you want to get indexes you can add in PDFVPage class two methods:
- (int)GetSelStartIndex
{
    return [m_sel getStartIndex];
}
    
- (int)GetSelEndIndex
{
    return [m_sel getEndIndex];
}
And when you want to reuse them just call the method addAnnotMarkup and passing indexes

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

Get StartIndex and EndIndex of highlighted text 7 months 3 weeks ago #13415

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0
hi,
I have place these two methods in PDFVPage but its showing as "No visible @interface for 'PDFVSel' declares the selector 'getStartIndex'" and No visible @interface for 'PDFVSel' declares the selector 'getEndIndex'

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

Get StartIndex and EndIndex of highlighted text 7 months 2 weeks ago #13418

  • federico
  • federico's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 50
  • Thank you received: 4
Hi,
Try to add this code PDFVPage.h in the PDFVSel inferface:
@interface PDFVSel : NSObject
//some other code
- (int)getStartIndex;
- (int)getEndIndex;
@end
and so these methods will be visible to others classes.

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

Powered by Kunena Forum