How to use the epubjs.Book function in epubjs

To help you get started, we’ve selected a few epubjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Janglee123 / eplee / src / shared / dbUtilis.js View on Github external
function getInfo(filePath, callback) {
  // parameter validation
  if (!filePath || typeof filePath !== 'string') {
    return;
  }

  // create a key from path
  const key = genrateKey(filePath);

  // file load on file protocol
  const uri = fileUrl(filePath);
  const book = new Book(uri);

  book.ready
    .then(() => {
      return book.locations.generate();
    })
    .then(locations => {
      const meta = book.package.metadata;

      const info = {
        id: key,
        title: meta.title,
        author: meta.creator,
        publisher: meta.publisher,
        path: uri,
        bookmarks: [],
        highlights: [],
github Janglee123 / eplee / src / renderer / views / Reader.vue View on Github external
mounted() {
    const { id } = this.$route.params;
    this.info = this.$db.get(id);
    this.toc = this.info.toc;
    this.info.lastOpen = new Date().getTime();
    this.buble = this.$refs.bubleMenu
    this.book = new Book(this.info.path);

    this._flattenedToc = (function flatten(items) {
      return [].concat(...items.map(item => [item].concat(...flatten(item.children))));
    })(this.toc);

    this._flattenedToc.sort((a,b)=>{
      return a.percentage - b.percentage;
    })

    this.rendition = new Rendition(this.book, {
      width: '100%',
      height: '100%',
    });

    this.rendition.on('rendered', (e, iframe) => {
      clickListener(iframe.document, this.rendition, this.flipPage);

epubjs

Parse and Render Epubs

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages