I'm writing an app that manages documents for a user and (eventually) posts PDF files served out through a web service on the iPhone/iPad. These are almost exclusively scanned PDF files, and they appear to REALLLLLY bog down the iOS device.
The first solution I came up with was to simply host the PDF in a UIWebView. This works really, really well for "generated" PDF files, but NOT for scanned PDF files (I'm guessing the difference here is raster vs. vector?).
My next solution was to implement a UIDocumentInteractionController, which was said to increase snappiness. I can report that it does, indeed, seem to be faster than UIWebView, but it's still unacceptably slow, even on smallish, 2 page PDF files. (On a side note, the "auto-open-in-another-app" feature, along with built-in printing is super slick!)
I've read a post or 2 about the QuickLook framework, and I plan to look into that, but I've also stumbled across a few posts talking about CGPDFDocument classes and such. Those seem to have a finer control over document navigation (a la xPdf), but I have no idea where to start with that. Plus, I'm not even sure if it offers a performance benefit for what I'm doing.
So, first question: what's the fastest way to render scanned PDF files on the iPhone/iPad?
Second question: The scanned PDF files are generated by my company, so I have some control over the PDF generation settings. Does anybody know what settings might improve load speed for image-based PDF files?
Thanks!
(By the way: I've been coding for 19 hours straight today, so if I rambled or didn't make sense, please forgive me! :) )
The fastest solution will be to write your own custom pdf parser and rendering framework using the CGPDFDocument classes. The secret to superfast pdf rendering is using techniques like:
I used all of the above mentioned techniques in PDFTouch SDK for iOS which is a fast pdf rendering framework developed by me!
You may wanna try to reduce image size. Large PDFs are really pushing the iPad/iPhone to its limits. Of course this means that you need to draw/manage the pdf yourself, with Quartz calls.
More speed is possible with proper caching. You can render pages off-screen, and display them without opening the actual pdf - which is much, much faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With