使用drawLayer for ipad渲染后在PDF上进行文本选择 [英] Text selection on PDF after rendering using the drawLayer for ipad

查看:168
本文介绍了使用drawLayer for ipad渲染后在PDF上进行文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在ipad上渲染后突出显示pdf上的文字。我觉得我正在通过大量的谷歌搜索和 fastPdfKit 。通过此链接,我轻松解析PDF并尝试突出显示用户搜索中的文本。我使用下面的方法来获取文本边界:

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)

我接受建议。

谢谢。

推荐答案

(NSArray *)searchResultOnPage:(NSUInteger)pageNr forSearchTerms:(NSString *)searchTerm 返回 MFTextItems 的NSArray。 MFTextItem 有一个名为 highlightPath 的属性,它返回 CGPathRef 。这是你在用什么?

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

如果你需要从 highlightPath 获得CGRect,你可以使用 CGPathGetBoundingBox

If you need to get a CGRect from the highlightPath, you could use CGPathGetBoundingBox.

如果 highlightPath 不够准确你,你必须要有创意,并自己想出一个解决方案。

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.

这篇关于使用drawLayer for ipad渲染后在PDF上进行文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆