渐进式pdf下载
我想在 iPad 应用程序中逐步下载 pdf 文件。我不知道该怎么做,谷歌也没有太大帮助。谁能帮我理解这里的概念。我计划在核心图形中渲染。 谢谢。
I want to download a pdf file progressively in an iPad application. I m not sure how to do that and google wasn't very helpful. can anyone help me understand the concepts here please. I am planning to render in core graphics.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的意思是您想在下载完成之前渲染 pdf 页面吗?如果是:
首先,PDF 格式最初并不是为此设计的。
让我解释一下。 PDF 文件由许多对象和外部参照组成。外部引用是一个包含文件中每个对象的位置(从开头开始以字节为单位)的表,因此对象可能位于文件中的随机位置。更糟糕的是,外部参照本身位于文件末尾,因此在下载文件之前您无法找到文件中的任何对象。
因此,PDF 是为随机访问而设计的。实际上,HTTP 协议允许这样做,所以如果您确实需要它,您可以尝试实现它:)
好消息:从 PDF-1.2 开始,有一个称为“线性化 PDF”的特殊功能。它是专门为您的任务而设计的,因此您可以在下载后渲染下一页之前渲染第一页。您可以通过谷歌搜索或查看 pdf 参考资料以获取更多详细信息。最重要的是:您必须使用特殊工具对 pdf 文件进行线性化,因此并非每个 pdf 文件都可以逐步渲染。
对你来说坏消息:看起来核心显卡不支持。我实际上没有尝试过,但我在核心图形文档中没有发现任何重新线性化的pdf。 (如果您找到任何内容,请告诉我。)因此您可能需要手动渲染 PDF。
Do you mean you want to render pdf pages before download is completed? If yes:
First of all, PDF format initially was not designed for that.
Let me explain. PDF file consists of a number of objects and xref. xref is a table containing location (in bytes from the beginning) of every object withing the file, so objects may be located at random locations withing the file. Even worse, xref itself is located at the end of file, so you can't locate any object in the file until you download it.
So, PDF is designed for random access. Actually, HTTP protocol allows it, so if you really need it, you can try to implement it :)
Good news for you: starting from PDF-1.2 there is a special feature called "Linearized PDF". It is designed exactly for your task, so you can render the first page before the next one if downloaded. You can google around or check out pdf reference for more details. The most important thing: you have to linearize pdf file using special tools, so not every pdf file can be rendered progressively.
Bad news for you: looks like core graphics doesn't support. I didn't tried it actually, but I found nothing re linearized pdf in core graphics documentation. (Please let me know if you will find anything.) So you may need to render PDF manually.
不完全确定 iPad 的情况,但在 Acrobat 中执行“另存为...”时,默认情况下它将被优化为“快速 Web 视图”,它允许一次下载一个页面,而不是一次性下载整个文档。
http://www.adobe.com/designcenter-archive/acrobat /articles/acr6optimize/acr6optimize.pdf
Not entirely sure about for iPad, but doing a Save as... in Acrobat by default it will be optimized as Fast Web View, which allows downloads a page at a time instead of the whole document in one go.
http://www.adobe.com/designcenter-archive/acrobat/articles/acr6optimize/acr6optimize.pdf
线性 PDF 将满足您的需求需要。您需要一个有能力的阅读器(例如 Adobe 的阅读器)才能使用此功能。
Linearzied PDF will meet your needs. You need a capable reader such as the one from Adobe to utilize this feature.