I’ve seen 2 approach to doing this which is via UIWebView and using Quartz framework to draw the pdf pages. I’ve heard sluggishness problems using the UIWebView and it’s not as flexible as using the latter method.
As a newbie iOS programmer,
1) what topics should I learn first (which frameworks/controls/library before going ahead and learning the Quartz PDF support)?
2) Is there anything new in iOS5/latest beta of Xcode related to this?
Any suggestions and/or samples available would really help.
Although Apple stated “better PDF support” in their Keynote, there’s no visible difference between iOS4 and new releases. Could be that they improved PDF parsing internally, but that’s pure speculation on my side.
Using UIWebView for pdfs isn’t really that great. Apple introduced QuickLook in iOS4 for that, which is a bit faster and cleaner compared to the webview.
If you want to get more speed, more features, you have to dig into the Quartz CGPDF* functions, and getting that right and fast is a real PITA. Especially since there’s so much stuff you don’t even know, e.g. that PDFs can have rotation information, Crop/Media boxes and so on. For fast scrolling, you also need some kind of UIScrollView that reuses it’s internal views to be speedy.
And be really careful with CATiledLayer (which you need to allow fast zooming) – because that one works multithreaded and really loves crashing in your face, when you don’t end rendering correctly. (Must importantly nil out it’s delegate, and maybe even it’s content. But nilling out the content waits for threads and may block the main view.)
If you still wanna do it yourself, Apple’s Zooming PDF Viewer Example is a start. Although it doesn’t handle rotation or cases where the Crop/Media Box has negative values – and there’s also no page-scrolling.