Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read EPUB book using EPUBLIB?

I found a solution for reading epub books in android using epublib. I am able to read the subtitles of the book. But I didn't find a way to read the line by line of the content. How can I acheive this?

Sample code for getting titles of the book is

  private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
    if (tocReferences == null) {
        return;
    }
    for (TOCReference tocReference : tocReferences) {
        StringBuilder tocString = new StringBuilder();
        StringBuilder tocHref=new StringBuilder();
        for (int i = 0; i < depth; i++) {
            tocString.append("\t");
            tocHref.append("\t");
        }
        tocString.append(tocReference.getTitle());

        tocHref.append(tocReference.getCompleteHref());
        Log.e("Sub Titles", tocString.toString());
        Log.e("Complete href",tocHref.toString());

        //logTableOfContents(tocReference.getChildren(), depth + 1);
    }
}

Got this code from http://www.siegmann.nl/epublib/android

How can I get the story of the book...

like image 369
Taruni Avatar asked Jul 01 '11 09:07

Taruni


1 Answers

Well - i'm not exacly sure about navigating, but also wonder how to do it For now - i have something like this (it is line - by line read):

private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
    if (tocReferences == null) {
        return;
    }
    for (TOCReference tocReference : tocReferences) {
        StringBuilder tocString = new StringBuilder();
        for (int i = 0; i < depth; i++) {
            tocString.append("\t");
        }
        try{
           InputStream is = tocReference.getResource().getInputStream();
           BufferedReader r = new BufferedReader(new InputStreamReader(is));
           String line;
           while ((line = r.readLine()) != null) {
               String line = Html.fromHtml(line).toString();
           }
        }
        catch(IOException e){

        }




        //logTableOfContents(tocReference.getChildren(), depth + 1);
    }
}
like image 122
yacool Avatar answered Oct 14 '22 05:10

yacool