Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF

TOPIC:

Get StartIndex and EndIndex of highlighted text 6 years 4 months ago #13166

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 6 years 2 months 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 6 years 2 months ago #13398

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 6 years 2 months ago #13400

  • federico
  • federico's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 261
  • Thank you received: 18
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 6 years 2 months ago #13415

  • joshnaAppcare
  • joshnaAppcare's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 6 years 2 months ago #13418

  • federico
  • federico's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 261
  • Thank you received: 18
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