How to use the epubjs/lib/index 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 gerhardsletten / react-reader / src / modules / EpubView / EpubView.js View on Github external
initBook(first) {
    const { url, tocChanged, epubInitOptions } = this.props;
    if (this.book) {
      this.book.destroy();
    }
    this.book = new Epub(url, epubInitOptions);
    this.book.loaded.navigation.then(({ toc }) => {
      this.setState(
        {
          isLoaded: true,
          toc: toc
        },
        () => {
          tocChanged && tocChanged(toc);
          this.initReader();
        }
      );
    });
  }
github marcojrfurtado / bookweave / src / tools / ebook.js View on Github external
const loadMetadata = async(eBookName, rawEBookData) => new Promise(async (resolve, reject) => {
    
    try {
        var doc = undefined
        var inputMetadata = undefined
        var fingerprint = undefined

        if (eBookName.endsWith(".epub")) {
            doc = new Epub(rawEBookData, {});
            inputMetadata = await doc.loaded.metadata
            fingerprint = inputMetadata.identifier
        } else {
            reject("Unkown eBook format.")
        }

        var outputMetadata = {}

        outputMetadata['fingerprint'] = fingerprint
        outputMetadata['author'] = inputMetadata.info ? inputMetadata.info.Author : inputMetadata.creator
        outputMetadata['fileType'] = "epub"
        outputMetadata['Content-Type'] = "application/epub+zip"
        outputMetadata['title'] = inputMetadata.info ? inputMetadata.info.Title : inputMetadata.title
        outputMetadata['searchTitle'] = createSearchPattern(outputMetadata.title)
        outputMetadata['searchAuthor'] = createSearchPattern(outputMetadata.author)
        outputMetadata['isbn'] = guessISBNInIdentifier(outputMetadata.fingerprint)