使用CGPDF API在iPad中显示PDF [英] Show PDF in iPad using CGPDF APIs
问题描述
我了解到Apple已经在SDK 3.2中发布了用于绘制PDF上下文的CGPDF API。
I have learned Apple has release CGPDF APIs in SDK 3.2 for drawing PDF context.
我从这些API中了解到,您可以将PDF绘制到数据对象或PDF文件中。然后,您可以将其导出到沙箱的目录中,或者作为附件添加到邮件中。
What I understand from these APIs is that you can draw a PDF to a data object or a PDF file. You can then export it, may be, to your sandbox's directory OR add as an attachment in the mail.
但我不确定我们是否可以使用这些API从应用程序包中读取PDF并在屏幕上逐页显示给用户。我想要做的是在杂志阅读器应用程序中打开杂志的PDF。
But I am not sure if we can use these APIs to read a PDF from application bundle and show it to the user page-by-page on the screen. What I want to do is open a PDF of a magazine in a magazine reader app.
我还想知道我们是否可以识别PDF文件中的链接并打开它们在应用程序中。
I was also wondering if we can identify the links in a PDF file and open them in the app.
让我知道是否做过或做过这样的事情。
Let me know if have done OR doing anything like this.
谢谢
AJ
Thanks AJ
推荐答案
在API文档中,有一种加载PDF的方法(使用Quartz):
CGPDFDocument 是你需要的对象
和 CGPDFDocumentCreateWithURL 可能是你正在寻找的构造函数。
In API documentation there is a way to load a PDF (with Quartz): CGPDFDocument is the object you need and CGPDFDocumentCreateWithURL is probably the constructor you are looking for.
Here are some examples on how to do it: http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html#//apple_ref/doc/uid/TP30001066-CH214-TPXREF109
我花了很多时间在这上面 - 似乎你需要使用CATiledLayers来正确缩放这些PDF!
I have spent a lot of time on this - and it seems you need to use CATiledLayers to zoom those PDFs properly!
有一些好处网上有关如何做到这一点的例子...
There are some good examples on the net on how to do that...
我会在准备就绪后立即提供链接/解决方案!
I will put a link/solution here as soon as I have something ready!
这篇关于使用CGPDF API在iPad中显示PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!