Split Pdf into pages for display on UIPageViewController

I have a PDF document that comes from the server and I would like it to display it on the UIPageViewController on the iPad to give it a nice page curl 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. Does anyone know how I can do this? What do you recommend when breaking pdf into a set of PDF files or pngs.I am not afraid with CGPdfPageRef, so I can not use UIWebview, Thanks

+6
source share
2 answers

Your idea is absolutely correct.

UIPageViewController can work with a data source (like a table view controller). Each page requires a UIViewController object.

So the idea is that the page view datasource controller creates a CGPDFDocumentRef from your pdf file / url, selects each page CGPDFDocumentGetPage(pdfDocRef, pageNumber) creates a view controller object that can display this page and returns it using data source methods .

You will get a lot of documentation / code to help you render the CGPDFPageRef. Its pretty easy.

+7
source

I created a project that shows every page of a PDF file in a UIPageViewController using the methods described by lukya. You can download the source code from GitHub here .

+5
source

Source: https://habr.com/ru/post/910592/


All Articles