Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split Pdf into pages for displaying on UIPageViewController

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

like image 303
Qamar Suleiman Avatar asked Mar 13 '12 13:03

Qamar Suleiman


2 Answers

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.

like image 95
Swapnil Luktuke Avatar answered Nov 10 '22 12:11

Swapnil Luktuke


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.

like image 28
Jack Humphries Avatar answered Nov 10 '22 12:11

Jack Humphries