Roger_iPhone
Roger_iPhone

Reputation: 827

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

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 ?

Upvotes: 12

Views: 6395

Answers (2)

user907729
user907729

Reputation:

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.

Upvotes: 10

DagonAmigaOS
DagonAmigaOS

Reputation: 61

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.

Upvotes: 0

Related Questions