Search code examples
androidcordovaepub

Epub Reader example Issue


I try to read epub file content to convert book formats using phonegap technology.i found examples using phonegap as shown below link:

http://bytedebugger.wordpress.com/2014/05/21/cordovaphonegap-ebook-reader-for-web-and-mobile-with-epub-js-plugin/

In this examples i am tries to implements basic epub example.I tries code as shown below :

  <!DOCTYPE html>
<html class="no-js">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Basic ePubJS Example</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
        <meta name="apple-mobile-web-app-capable" content="yes">


        <!-- EPUBJS Renderer -->
        <script src="../build/epub.min.js"></script>

         <!-- Zip JS -->
        <script src="../build/libs/zip.min.js"></script>  

         <!-- Inflate JS -->
        <script src="../build/libs/inflate.js"></script>  


        <script>

            EPUBJS.filePath = "../build/libs/";

        </script>

         <script>
            var Book = ePub("content.epub");//here epub file path given
        </script>
    </head>
    <body>
        <div id="main">
          <div id="prev" onclick="Book.prevPage();" class="arrow">‹</div>
          <div id="area"></div>
          <div id="next" onclick="Book.nextPage();"class="arrow">›</div>
        </div>

        <script>            

            Book.renderTo("area");

        </script>
    </body>
</html>

Error : The operation is insecure. undefined

The above example not gets any output it shows empty.I didn't get any idea about this.So can you please suggest me what to do for this?

Thanks in Advance.


Solution

  • First, reading this documentation: https://github.com/futurepress/epub.js/blob/master/README.md you will see an important part:

    If you plan on using compressed (zipped) epubs (any .epub file) include the minified version of zip.js

    Also make sure to set EPUBJS.filePath to the directory containing inflate.js

    <script src="/build/libs/zip.min.js"></script>  
    
     <script>
         EPUBJS.filePath = "../build/libs/"; 
    </script>
    

    So, the first thing you need to do is to add theses libs.

    Some browsers can block the access of a file, so if you have problems, maybe you will need to use it with a web server.