在 iPad 中加载 PDF

发布于 2024-11-30 13:04:55 字数 297 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花间憩 2024-12-07 13:04:55

您是否运行过 Instruments 来查看时间都花在哪里了?

Have you run Instruments to see where the time is spent?

雾里花 2024-12-07 13:04:55

我建议你使用大量的预缓存来解决这个问题。根据我的经验,分析 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文