16
votes

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.

1
FastPdfKit automatically highlights search results, i didn't understand why you need some other informations.MacTeo
that is iphone app and the use those own transformation and that is not available to us.now coming to my issue i have my own transformations if my transformations and fastpdfkit transformations same then i can highlight the text.ajay
@MacTeo please stop spamming your closed library around. "i didn't understand why you need some other informations" Maybe because he wants to learn how to do it on his own?pt2ph8
@pt2ph8 the question contains a FastPdfKit method asking for a solution. Am i spamming trying to reply? Sorry if i did it.MacTeo
hi guys this is not at all spamming y bec still i didnt find solution..ajay

1 Answers

3
votes

(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.