I'm trying to highlight the text on the pdf after rendering on the ipad.I feel I'm achieving something with a lot of googling and the sample code provided by fastPdfKit. From this link I am parsing a pdf easily and trying to highlight text from a user search. I am using the below method to get text bounds:
-(NSArray *)searchResultOnPage:(NSUInteger)pageNr forSearchTerms:(NSString *)searchTerm withProfile:(MFProfile *)p;
This method gives me an array of objects from which I am getting the rect but it is not exactly the searched word bounds.
Can anyone tell me whether this is the correct way to go or not, and please tell me how to get the text bounds correctly. Some how this question is duplicate of my last question (old)
I accept suggestions.
Thank you.
(NSArray *)searchResultOnPage:(NSUInteger)pageNr forSearchTerms:(NSString *)searchTerm
returns an NSArray of MFTextItems. MFTextItem
has a property called highlightPath
that returns a CGPathRef
. Is that what you are using?
If you need to get a CGRect from the highlightPath
, you could use CGPathGetBoundingBox
.
If the highlightPath
is not accurate enough for you, you are going to have to be creative and come up with a solution on your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With