问题描述
我想要强调的PDF文本,并有突出的矩形文本下绘制。
i'm trying to highlight text in a pdf, and have the highlighted rectangle to be drawn under the text.
它工作正常,在大多数PDF文件,但我跳进一个问题,当我试图突出显示文本下设的图像/背景。问题是,在突出显示矩形的图像下拉伸为好,因此它是不可见的。
It works fine on most PDF's, but I jumped into a problem when the text I'm trying to highlight has an image/background under it. The problem is that the highlight rectangle is drawn under the image as well, so it is not visible.
描绘顺序我已经是这样的:
The drawing order I have is this:
- 绘制页面大小的空白矩形
- 绘制亮点
- 绘制使用CGContextDrawPDFPage(背景下,页)的PDF;
有没有一种方法来绘制PDF图像和文字分开?这样我就可以去
Is there a way to draw the PDF images and text separately? so that I could go
- 空白矩形
- PDF图像/背景
- 亮点
- PDF文本
难道我有那么它会自动绘制它,我希望它的方式做一些事来的PDF /背景?我试着与上下文搞乱,但没有到目前为止的工作,这一切都在完全或以上的全PDF完全取自
Do I have to do something to the pdf / context so that it draws it automatically the way I want it to? I've tried messing with the context but nothing worked so far, it's all drawn entirely under or entirely above the full pdf
每一个我所见过的读者做到这一点(PDFExpert,GOODREADER,iAnnotate仅举几例),因此它不能是不可能的,我只是还没有找到解决办法:)
任何帮助将有所帮助,在此先感谢!
Every reader I've seen does this (PDFExpert, GoodReader, iAnnotate to name a few), so it can't be impossible, I just haven't found the solution yet :)Any help will help, thanks in advance!!
干杯
推荐答案
我的理解是,这些其他应用程序在读取和渲染PDF本身(它们还可以支持选择文本,或添加注释,例如),这样他们就能够更容易地层中你提的事物的方式。
My understanding is that these other apps are reading and rendering the PDF themselves (they support selecting text, or adding annotations, for example), so they would be able to much more easily layer things in the way you're mentioning.
你开始与该CGPDFDocument是一个不透明的对象(在OO意义上,不透明度),可以自行绘制,但我不知道有什么方法打出来,并呈现文档的各个子层。
The CGPDFDocument you're starting with is an opaque object (in the OO sense, not transparency) that can draw itself, but I don't know of any way to break out and render various sublayers of the document.
作为前进的方向,你可以看看使用核心映像(的iOS5 +)或其他方法融合与PDF的亮点层。如果你使用正确的过滤器(乘,也许),颜色较深的文字将仍然来通过和0.3阿尔法亮点将与任何背景融为一体。
As a way forward, you could look at using Core Image (iOS5+) or some other method to blend the highlights layer with the PDF. If you used the right filter (Multiply, maybe), the darker text would still come through and a .3 alpha highlight would blend with any background.
这篇关于PDF突出上述图片/文字下方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!