Fousa
Fousa

Reputation: 535

Paging a UIScrollView with a large PDF

I try to create a simple UIScrollView with paging. And I want to be able to scroll through a large PDF document, but this gives me some problems...

I tried the following options:

And I prefer not to load everything at startup but to do it during the usage.

Did anyone did this recently? Can't seem to find a nice example project.

Thnx!

Jelle

Upvotes: 1

Views: 3677

Answers (3)

Emrah Ayanoglu
Emrah Ayanoglu

Reputation: 466

This problem is one of the most known problems of the PDF rendering. The solution is to cache the limited number of pdf pages. You cannot cache all of the pages when you have larger pdf files because of the scarcity of memory of ios devices.

For instance Goodreader(One of the best iOS PDF Reader Application) uses caching mechanism, too. Goodreader caches 3 pages when you flip page; however they have problem when you flip pages faster.Since, loading the new pages needs longer times.

You firstly start with Goodreader's solution such as you start caching with previous, current and next page. When user flips the page, then you should cache the prev or next pages.

If I give an example;

Starting point(Load two pages to the memory with background thread because of the performance issues):

prev = nil;
current = page1;
next = page2;

When user flips to the next page;

prev = page1;
current = page2;
next = page3 //(Load into the cache);

With this solution logic, you have chance to load more than 3 pages into your memory

Upvotes: 1

Jason Terhorst
Jason Terhorst

Reputation: 11

ZoomingPDFViewer won't really help here. It doesn't cover paging, and doesn't cover faster loading. This may help you a bit: http://cocoawithlove.com/2009/01/multiple-virtual-pages-in-uiscrollview.html Draw your PDFs into a custom view. That seems to be the most efficient technique.

Upvotes: 0

TomSwift
TomSwift

Reputation: 39512

Check out Apple's ZoomingPDFViewer sample:

http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html

Upvotes: 2

Related Questions