在 iPad 中加载 PDF
我正在使用 CGContextDrawPDFPage 类在我的应用程序中渲染 PDF,没有任何问题。但是,加载书籍所需的时间要多一些,并且渲染页面所需的时间与 PDF 中的页数成正比。
就我而言,PDF 可以包含 500 到 1000 页之间的任意位置。因此,我的 PDF 的加载时间越来越长。渲染第一页几乎需要 10 秒,从用户体验角度来看,这确实很糟糕。并且这个时间仅在第一次加载书籍时进行。在我看来,延迟是由于我试图立即阅读整个 PDF。
有没有一种方法可以让我可以部分阅读 PDF,以便渲染 PDF 的初始时间更快。
谢谢。
I am using CGContextDrawPDFPage class to render PDF in my app without any trouble. But, the amount of time taken to load the book is a bit more and the time taken to render the page is proportional to the number of pages in the PDF.
In my case, the PDF can contain anywhere between 500 to 1000 pages. Due to this, the loading time of my PDF is getting increased. It is almost taking 10 seconds to render the first page which is really bad from a user experience aspect. And this time is being taken only during the loading of the book for the first time. In my opinion the delay is due to the fact that i am trying to read the entire PDF at once.
Is there a way in which i can read the PDF part by part so that the initial time to render the PDF is faster.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否运行过 Instruments 来查看时间都花在哪里了?
Have you run Instruments to see where the time is spent?
我建议你使用大量的预缓存来解决这个问题。根据我的经验,分析 PDF(长宽比内容、注释等)需要一些时间。画图也很慢。
我通过动态预生成图像并尽可能显示它们来解决这个问题。当然这也很棘手,例如,不要尝试同时在屏幕上和屏幕外渲染,绘制复杂的 pdf 时的内存使用量超出范围,并且同时执行两个操作可能会使您的应用程序崩溃。
I suggest you use heavy pre-caching to solve the problem. In my experience, analyzing the PDF (for aspect ratio stuff, annotation, etc) takes some time. Drawing is slow too.
I solved this with pre-generating images on the fly, and showing them whenever possible. Of course this is tricky too, e.g. don't ever try to render on and off screen at the same time, memory usage while drawing a complex pdf is off-scale and performing two operations at the same time may just crash your app.