Bhupendra
Bhupendra

Reputation: 2545

How to give pagination in reading a e-pub format book (just like iBook shows pagination)?

I need to display e-pub books, so I used a webview to display the e-pub book and I am able to display the book chapter-wise instead of page-wise. Can anyone please help me so that i can paginate the epub

Upvotes: 2

Views: 1097

Answers (1)

Stream
Stream

Reputation: 9493

To paginate ePub, you have to extensively use WebView and column layout with custom CSS. Here is a typical workflow for each chapter:

  1. Create an in-memory or off-screen WebView component with required width and height;
  2. Load a chapter HTML with injected <script src="[local path]"></script> tag;
  3. JavaScipt code should enclose the whole content into one div tag using DHTML;
  4. Also, JavaScript should inject CSS with a property column-width set for that div tag;
  5. When WebKit engine completes rendering, you receive an event in JavaScript;
  6. Once you get the event, it's time to count how many pages is in HTML: clientWidth / width.

Then, you can use the same technique to render ePub into UIViewController, but this time on screen. While rendering how many pages are in ePub, you may want to display a progress indicator.

Upvotes: 2

Related Questions