본문 바로가기
eBook

ePub Viewer 소스 확인 1 - EPUB Viewer for Android with Text to Speech / Code Project

WebView기반 리더..

페이지 처리조차 안되어있고..

챕터 사이 이동시 오류 많음.

 

 

http://www.codeproject.com/Articles/592909/EPUB-Viewer-for-Android-with-Text-to-Speech

 

Introduction 

This application shows the basics of building an EPUB file viewer for Android.

The features of the viewer are:

  • A "list view" of the .epub files on the SD card.
  • A "list view" of the book's Table of Contents (ToC), with the ability to select a ToC entry, and jump to it.
  • Viewing an EPUB's contents.
  • Ability to set a bookmark and return to the bookmark.
  • Using Android's Text to Speech API to read the book aloud.

What this article will cover:

  • A summary of the EPUB file format, and the steps involved in reading it.
  • How to use the android.sax library to parse an EPUB file.
  • How to use the android WebClient to display HTML, including:
    • Using Android 3.0's shouldInterceptRequest() to fetch the HTML to display.
    • Web Client differences between Android 2.3 and 3.0.
    • Dealing with the Web Client's caching
    • Getting the current scroll position of the HTML document
    • Restoring the scroll position, when a document is reloaded
    • Adding "Fling" gesture handling to the WebClient
    • Formatting URIs
  • How to set up a chain of XMLFilters to process an XML document with a SAX parser.
  • Converting a SAX parser's output back into XML.
  • Using Parcelable to package data into an intent, for passing to an activity.
  • Using Android's Text to Speech API

Caution, as this project is intended to show the basics of viewing an EPUB file, there's a number of simplifying assumptions I've made.

  • All files are UTF-8, don't handle UTF-16
  • Language is English (only really relevant for Text to Speech)
  • The EPUB files are well formed. (No error handling in XML parsing.)
  • Only supporting EPUB 2.0 (and a limited set at that, e.g. minimal SVG support, not all manifest attributes.)

Using the code

If you don't know how to set up Eclipse and the Android SDK, go here for instructions.

Download the project, unzip and import into Eclipse. Requires minimum of Android 2.3

EPUB File Format and Parsing an EPUB

Wikipedia provides a good description of EPUB format, including links to the official documentation. For those of you who don't want to read it, here's the 30 second executive summary. An EPUB file is ZIP file that contains HTML files and images (often in multiple folders) and a few XML files. The HTML (actually XHTML) files and images are the content of the book. The XML files are metadata, covering things like:

  • Information on the book itself, e.g. Title, Author(s), Publisher, etc.
  • Details of the HTML files. e.g. Format for each file, order to read them in, which file corresponds to each chapter of the book, etc.
  • The table of contents.

As the EPUB file is a zip file, the first thing we need is a function that allows us to extract the files from a zip file. We can use the java.util.zip.ZipFile class in Android to do most of the work for us.

 

 

 

'eBook' 카테고리의 다른 글

독일 도서시장, 전자도서(E-Book)가 이끈다  (0) 2013.10.26