Qamar Suleiman
Qamar Suleiman

Reputation: 1226

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

Upvotes: 6

Views: 3439

Answers (2)

Jack Humphries
Jack Humphries

Reputation: 13267

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.

Upvotes: 5

Swapnil Luktuke
Swapnil Luktuke

Reputation: 10475

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.

Upvotes: 7

Related Questions