Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text selection on PDF after rendering using the drawLayer for ipad

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.

like image 233
ajay Avatar asked Mar 18 '11 15:03

ajay


1 Answers

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

like image 143
Michael Frederick Avatar answered Nov 16 '22 00:11

Michael Frederick