Skip to content

Releases: RussCoder/djvujs

L:: v.0.2.1; V:: v.0.2.1

20 Aug 18:27
Compare
Choose a tag to compare

How to use it:

<!DOCTYPE html>
<html>

<header>
    <meta charset="utf-8">
    <script src="djvu.js"></script>
    <script src="djvu_viewer.js"></script>
    <link href="djvu_viewer.css" rel="stylesheet">

    <script>
        window.onload = function () {
            // save as a global value
            window.ViewerInstance = new DjVu.Viewer(); 
            // render into the element
            window.ViewerInstance.render(
                document.querySelector("#for_viewer")
            );
        };
    </script>

    <style>
        /* make it pretty-looking */

        body {
            height: 100vh;
            margin: 0;
        }

        #for_viewer {
            height: 80vh;
            width: 90vw;
            margin: 5vh auto;
            border: 1px solid black;
        }
    </style>

</header>

<body>
    <div id="for_viewer"></div>
</body>

</html>

Furthermore, the viewer has a program API, which allows to open djvu files programmatically:

  • loadDocument(buffer, name) - which accepts the ArrayBuffer and a name of a document which should be shown at footer(it's optional).
  • async loadDocumentByUrl(url) - which loads the documents as an ArrayBuffer and then invokes the previous method.

L:: v.0.2.0; V:: v.0.1.7

05 Aug 15:12
Compare
Choose a tag to compare

How to use:

<!DOCTYPE html>
<html>

<header>
    <meta charset="utf-8">
    <script id="djvu_js_lib" src="djvu.js"></script>
    <script src="djvu_viewer.js"></script>
    <link href="djvu_viewer.css" rel="stylesheet">

    <script>
        window.onload = function () {
            DjVu.Viewer.init(
                document.querySelector("#for_viewer")
            );
        };
    </script>

</header>

<body>
    <div id="for_viewer"></div>
</body>

</html>