Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement an ePub reader for an iPad/iPhone app [closed]

I want to implement an ePub reader for the iOS platform. Please suggest any open source code for book flipping animation, bookmarks, font-size customization and single page view (without scroll bars).

like image 853
Kanak Vaghela Avatar asked Sep 03 '12 05:09

Kanak Vaghela


People also ask

Can an iPad open ePub files?

Opening the ePUB in the iBooks app On your iPad, open the email you have been sent with the files. Hold down the icon for the ePUB file attachment. A menu should open which says Open In. Select iBooks.

Does iOS have an ePub reader?

The Neat Reader iOS version is an ePub reader developed specifically for iOS and currently supports iOS 9.0 and above. As long as your iOS device system version is 9.0 or higher, you can use Neat Reader to read ePub files.


1 Answers

As the previous article points out, there is no API that given an ePub will just display it -- you need to do some work:

  1. Unzip the ePub
  2. Read the manifest file and metadata file to find the xhtml documents to display
  3. Load the xhtml documents into a UIWebView using a file:/// URL to the unzipped document

If you want to ensure that the documents don't hit the network you'll need to implement a custom NSURLProtocol and serve the bytes for the files yourself as file:/// allows cross domain access.

That will display the content just fine, but the "hard" part is moving between the documents (which usually represent a whole chapter). This is the work that iBooks and other apps do for you.

NOTE: For the UIWebView to display the content correctly, you have to ensure that the file has a .xhtml extension when using file:/// urls. If you implement your own URL protocol handler, you need to make sure the protocol handler returns the correct xml content type for xhtml, namely:

application/xhtml+xml

like image 80
tyr.kassat Avatar answered Sep 29 '22 14:09

tyr.kassat