javascript 如何使用javascript读取epub文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16933086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to read epub files using javascript
提问by RajeshKumar.K
How to read epub files using javascript?
如何使用javascript读取epub文件?
I tried epubjs but thats not suited for my requirement. Is any other alternative javascript libraries available?
我试过 epubjs 但这不适合我的要求。是否有其他替代的 javascript 库可用?
回答by Alberto Pettarin
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)
Readium Foundation 刚刚发布了 Readium Web Components:参见http://readium.org/news/annoucing-readiumjs-a-javascript-library-for-browser-based-epub-3-reading(代码: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/)
或者,您可能想看看 FuturePress:http: //www.futurepress.org/ (代码:https: //github.com/fchasen/epub.js/)
Finally, TEA also has something you might find interesting: https://github.com/TEA-ebook/teabook-open-reader
最后,TEA 还有一些你可能会觉得有趣的东西:https: //github.com/TEA-ebook/teabook-open-reader
回答by imal hasaranga perera
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,
很老的问题,TreineticEpubReader
是readium-js-viewer
我写的一个流行的分支,它提供了一个非常简单的 api 来与 epub 文件交互,
https://github.com/Treinetic/TreineticEpubReader
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
库是纯 javascript,所以你可以与任何现代框架混合和混合,这是一个示例代码,你也可以查看sample
里面的文件夹dist
以找到一个工作演示
<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");