About the EPUB Reader

This module is intended as a base framework for creating a digital version of a publication from an EPUB (eg, exported from InDesign).

What this module does

  1. Creates two node types: 'Reader Publication' and 'Reader Chapter'
  2. Upload the EPUB file into a new 'Reader publication' and save
  3. A batch process runs to automatically extract the EPUB and use the 'Spine' of the EPUB create (or update) Reader Chapters by EPUB Chapter ID
  4. Allows you to subsequently re-order, modify, and add additional chapters (eg, adding a video where the print publication would skip such rich media

Where it needs to be extended (ie, why is it a 'framework')?

  1. The module extracts the individual chapter xhtml files and during the batch import provides an instance of HtmlPageCrawler as well as the Reader Chapter being processed as an Event
  2. Subscribe to the Event (see the example module) and decide how you want to display it on your site. You could extract all contents as is to a WYSIWYG body field. You could extract contents into Paragraphs to create a more component-based approach.

What is HtmlPageCrawler

HtmlPageCrawler extends Symfony DomCrawler. It provides a jQuery-like approach to finding elements. For instance if you properly assign classes to your InDesign files, you could modify the title by grabbing the title of the chapter.

$title = $crawler->filter('.chapter_header')->first()->html();
$reader_chapter_node->set('title', $title);

Or similarly you could put quotes into a separate field:

foreach ($crawler->filter('blockquote') as $quote) {
  $reader_chapter_node->field_quotes[] = $quote->html();
}

Please see the documentation from HtmlPageCrawler and Symfony DomCrawler for more information.

Installation instructions

Install via composer to get the appropriate dependencies:

composer require drupal/epub_reader_framework

If you are not using composer you must make the following three dependencies available:

        "symfony/dom-crawler": "^3.0.0|^4.0.0|^5.0.0",
        "symfony/css-selector": "^3.0.0|^4.0.0|^5.0.0",
        "wa72/htmlpagedom": "^2.0.0"

Other modules to consider

If you just want to display an EPUB but not actually convert it to Nodes / Paragraphs / other Entities, you can simply use the epub module.

Work in progress

Soapbox has open sourced the foundation for creating Reader's for a InDesign (EPUB) files. Soapbox also offers the other way around - generating beautiful print-ready PDFs from long-form and short-form digital content. It uses a tool called Puppeteer to be able to achieve in print what can be achieved in digital (minus the interactivity of course).

Supporting organizations: 
Fully sponsoring initial development and maintenance

Project information

Releases