Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...