问题
How to read epub files using javascript?
I tried epubjs but thats not suited for my requirement. Is any other alternative javascript libraries available?
回答1:
Readium Foundation just released Readium Web Components: see http://readium.org/news/announcing-readiumjs-a-javascript-library-for-browser-based-epub-3-reading (code: https://github.com/readium/Readium-Web-Components )
Alternatively, you might want to have a look at FuturePress: http://www.futurepress.org/ (code: https://github.com/fchasen/epub.js/ )
Finally, TEA also has something you might find interesting: https://github.com/TEA-ebook/teabook-open-reader
回答2:
Quite old question, TreineticEpubReader
is a popular fork of readium-js-viewer
authored by me, it provides a very simple api to interact with epub files,
https://github.com/Treinetic/TreineticEpubReader
Library is pure javascript so you can blend and mix with any modern framework, here is a sample code, you can also look at the sample
folder inside the dist
to find a working demo
<div id="epub-reader-frame"></div>
var exControls = TreineticEpubReader.handler();
exControls.registerEvent("onEpubLoadSuccess", function () {
});
exControls.registerEvent("onEpubLoadFail", function () {
});
exControls.registerEvent("onTOCLoaded", function (hasTOC) {
if (!hasTOC) {
let toc = exControls.getTOCJson();
}
// you can use following api calls after this
/**
exControls.hasNextPage()
exControls.nextPage();
exControls.hasPrevPage()
exControls.prevPage();
exControls.makeBookMark();
exControls.changeFontSize(int);
exControls.changeColumnMaxWidth(int);
exControls.setTheme("theme-id-goes-here");
exControls.setScrollMode("scroll-type-id-goes-here");
exControls.setDisplayFormat("display-format-id-goes-here");
extcontrols.getRecommendedFontSizeRange()
extcontrols.getRecommendedColumnWidthRange()
var list = extcontrols.getAvailableThemes();
var list = extcontrols.getAvailableScrollModes();
var list = extcontrols.getAvailableDisplayFormats();
var settings = extcontrols.getCurrentReaderSettings();
**/
});
var config = TreineticEpubReader.config();
config.jsLibRoot = "src/ZIPJS/";
TreineticEpubReader.create("#epub-reader-frame");
TreineticEpubReader.open("assets/epub/epub_1.epub");
来源:https://stackoverflow.com/questions/16933086/how-to-read-epub-files-using-javascript