CGPDFDocument:打开 PDF 流或文件尚未完成?
情况:(
- 大)PDF 存储在 iOS 设备上
- PDF 使用 Rijndahl 算法加密
- 当点击其中一个 PDF 时,它会被解密,然后使用我实现的 PDF 查看器进行查看。查看器正在使用 Core Graphics 功能逐页呈现文档。
问题:
- 由于文档足够大,加密将需要一段时间。
- 只有在整个文档解密为临时文件后才能开始查看。
我想知道,是否有办法...
- 将某种流传递给 CGPDFDocument 而不是文件 URL
- 或任何其他替代方案,以便在解密时能够查看尽可能多的页面继续在后台?
Situation:
- (Large) PDFs are stored on an iOS device
- The PDFs are encrypted using a Rijndahl algorithm
- When tapping one of the PDFs, it gets decrypted and afterwards viewed using a PDF viewer I implemented. The viewer is using the Core Graphics functionality to render the document page by page.
Issue:
- With the documents being large enough, encrytion will take a while.
- Viewing can only be started after the whole document has been decrypted into a temp file.
I'm wondering, if there is a way to...
- Pass some kind of stream to
CGPDFDocument
instead of a file URL - Or any other alternative to be able to view as many pages as possible whil decrpytion is continued in the background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您无法将原始 PDF 文件拆分为单页(正如我怀疑的那样),那么以下方法应该有效:
A:仍在解密时:
尝试像您已经做的那样打开 PDF 文档;
尝试访问您感兴趣的文档页面;
如果没有失败,则渲染页面;
如果失败,那么您知道该页面尚不可用(解密时);
解密时,每次尝试获取新页面时释放pdf文档。
B:解密完成后:按照您已经做的那样进行。
请注意,这只是一个建议,我在解密文档时没有尝试过这一点,但如果第 1 点没有失败,那么这应该可以工作。
If you cannot split your original PDF files down to single pages (as I suspect), then the following approach should work:
A: When still decrypting:
try to open the PDF document as you already do;
try accessing the document page you are interested in;
if it does not fail, render the page;
if it fails, then you know that page is not available yet (while decrypting);
while decrypting, release the pdf document each time you try to get a new page.
B: when decryption is done: do as you are already doing.
Please note that this is just a suggestion, I have not tried this while decrypting a document, but if point 1. does not fail, then this should work.