I have a PDF document that comes from server and i would want it to display it upon the UIPageViewController on iPad in order to give it a nice page curling effect .The Only way I could think of is to split the PDF into pages and then use each page as a separate view controller.Do any one know how could i do that?.What do you recommend ,splitting pdf into a set of pdfs or a pngs.I am not afraid with CGPdfPageRef so I might not use UIWebview. Thanks
Your idea is absolutely correct.
UIPageViewController can work with a datasource (just like a table view controller). It takes a UIViewController object as each page.
So the idea is, page view controller's datasource creates CGPDFDocumentRef from your pdf file path/url, fetches each page CGPDFDocumentGetPage(pdfDocRef, pageNumber)
creates a view controller object which can render this page and returns it via datasource methods.
You'll get a lot of documentation/code to help you with rendering a CGPDFPageRef in your view. Its pretty easy.
I have made a project that shows each page of a PDF file in a UIPageViewController, using the methods described by lukya. You can download the source code from GitHub here.
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