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
- Creates two node types: 'Reader Publication' and 'Reader Chapter'
- Upload the EPUB file into a new 'Reader publication' and save
- 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
- 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')?
- 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
- 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).
Project information
- Module categories: Content Display
- 13 sites report using this module
- Created by scott_euser on , updated
- Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
Minor bug-fixes
Development version: 2.x-dev updated 5 Apr 2024 at 12:58 UTC