4

I referred this siegmann android tutorial and successfully logged the Title, Author name and Table of contents.

Now I read that the whole book can be viewed in WebView.

But I don't find any tutorial for Dispalying an ePub file.

When it comes to creating an ePub file, I found this from SO But I'm unable to implement it as I don't have any idea about main.xml.

Kindly suggest any tutorial to create and display an ePub file.

For creating ePub, I tried to refer this siegmann eg but I'm not able to understand it properly.

Do I need to provide .html for each chapter and .css in order to create an ePub file?

I know I'm little unclear in this qustion as I'm absolute beginner when it comes to working with ePub, so any suggestions/help appreciated.

Community
  • 1
  • 1
GAMA
  • 5,958
  • 14
  • 79
  • 126
  • follow this: http://stackoverflow.com/questions/10313113/taking-long-time-to-display-epub-files-in-device – skygeek May 04 '12 at 11:24

2 Answers2

2

Try this in logTableOfContents()

while ((line = r.readLine()) != null) {

line1 = line1.concat(Html.fromHtml(line).toString());

}

finalstr = finalstr.concat("\n").concat(line1);
musefan
  • 47,875
  • 21
  • 135
  • 185
Krunal
  • 6,440
  • 21
  • 91
  • 155
0

You can also spine the epub content with the help of

        Spine spine = book.getSpine(); 
        List<SpineReference> spineList = spine.getSpineReferences() ;
        int count = spineList.size();
        StringBuilder string = new StringBuilder();
        for (int i = 0; count > i; i++) {
            Resource res = spine.getResource(i);
            try {
                InputStream is = res.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                try {
                    while ((line = reader.readLine()) != null) {
                        linez =   string.append(line + "\n").toString();
                        System.err.println("res media"+res.getMediaType());
                        htmlTextStr = Html.fromHtml(linez).toString();
                        Log.e("Html content.",htmlTextStr);
                        speak(htmlTextStr);
                    }
                } catch (IOException e) {e.printStackTrace();}

                //do something with stream
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        webview.getSettings().setAllowFileAccess(true);
        webview.getSettings().setBuiltInZoomControls(true);
        webview.getSettings().setJavaScriptEnabled(true);

        webview.loadDataWithBaseURL("file:///android_asset/", linez, "application/xhtml+xml", "UTF-8", null);
Villan
  • 730
  • 1
  • 8
  • 26