How to show a PDF page by page using horizontal swipe in iphone?
Asked Answered
C

2

12

I want to create a page by page PDF reader.

I know how UIWebView can be used to show the PDF but It will load the entire PDF and want to show one page at a time.

The PDF is stored locally. Next and previous PDF Pages should be loaded depending on the horizontal swipe.

How to show a single page along with horizontal Swipe and Zooming functionalities ? What is the best approach for such problem? Is there any tutorial for this?

EDIT : I have used CGPDF APIs to show the PDF page by page. I am using the PDF page as image. But zooming is not working properly as UIPageControl is also used. How to zoom these images along with page control ?

Covariance answered 20/9, 2010 at 7:24 Comment(0)
S
10

You can use Leaves View, you can find tutorial from

https://github.com/brow/leaves

second option is FastPDFKit, you can get it from

http://mobfarm.eu/

According to me leaves is more preferable because memory management is good and it is more user friendly.

EDIT:

You can consider two more options which provide some good features for PDF.

  1. Reader on Github
  2. PSPDFKit

Note: PSPDFKit is not free.

EDIT: Since iOS 5, you can add an effect of swiping the page like iBooks. To do it that way you can use UIPageViewController. To get some basic idea, just create an app with page-based application from your Xcode template or you can refer to this link.

Slay answered 29/9, 2011 at 13:33 Comment(0)
H
0

you add as a subLayer the tiledLayer that draws the PDF page (CGContextDrawPDFPage) to a UIView and then you add that as a subview to a UIScrolView. That way you have a PDF page that you can zoom by pinching it and you can scroll.

Lets say you create a class PDFViewController:

[myContentView.layer addSublayer:tiledLayer]; ... [scrollView addSubview:myContentView]; ... [self.view addSubview:scrollView];

and then you should create MagazineViewController class where you have a large horizontal UIScrollView where you create the views from the PDFViewController that contain the pages, That way you have a view that you can swipe horizontally and see the pages of a magazine or a book.

Hereld answered 22/2, 2011 at 21:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.