This project is not covered by Drupal’s security advisory policy.
Turn your Drupal content into real ebooks -- no external binaries, no headless browsers, no special hosting.
Your reports, manuals, and documentation live in Drupal. Your readers want them on e-readers, tablets, and phones -- offline, accessible, and portable. ePub Generator bridges that gap: one click on any node, or on any Book outline, produces a valid ePub 3 file with proper publishing metadata, a navigable table of contents, and accessibility baked in.
Because it's pure PHP (built on the zero-dependency php-epub library), it runs anywhere Drupal runs, including managed hosting where installing wkhtmltopdf or a headless Chrome is not an option. All it needs is the `zip` and `dom` extensions your host already has.
Turn Book outlines into actual books
The Book Integration submodule is the flagship feature. If your organization already maintains structured long-form content in Book outlines, you get publishing for free:
- The entire book tree becomes a multi-chapter ebook with a hierarchical table of contents that mirrors your outline.
- Real publishing metadata -- author, ISBN, publisher, cover image, edition, rights -- is read from fields on your book's root node via a configurable field mapping. Your editors keep working exactly as they do today.
- A "Download ePub" tab appears on every node in the book.
Read in the browser, no download required
The Viewer submodule adds a "Read online" tab next to "Download ePub" -- an in-browser reader built on epub.js, with a table of contents, page-turning or continuous scrolling, progress, fullscreen, keyboard navigation, and automatic position resume. On a Book node, it opens the entire assembled book. A field formatter does the same for `.epub` files uploaded to file fields.
Accessibility is not an afterthought
Every generated ebook includes schema.org accessibility metadata (access modes, features, structural navigation) per the EPUB Accessibility specification, plus an ePub 2 NCX fallback for older reading systems -- relevant if you have Section 508, WCAG, or European Accessibility Act obligations for the documents you publish.
Features
- One-click downloads: a "Download ePub" tab on nodes, a route for any content entity, and Drush commands (`epub:generate`, `epub:generate-book`) for automation.
- In-browser reading: a "Read online" tab, an inline reader for uploaded ePub files, and response caching so books aren't rebuilt on every request.
- You control what's exported: a dedicated "ePub" view mode lets each content type define exactly which fields appear in ebook output, independent of the web display.
- Clean output: rendered HTML is converted to valid XHTML with Drupal UI (tabs, contextual links, admin links) stripped automatically. Local images are embedded; SVG and MathML are preserved for charts and equations.
- Fixed-layout support: produce pixel-perfect, pre-paginated ebooks (dashboards, illustrated content, children's books) -- book-wide or per chapter, with viewport, spread, and orientation control.
- Your branding: ship a sensible default stylesheet or point the module at your own CSS.
- Markdown submodule: attach `.md` files to any file field and offer them as ePub downloads, with YAML front matter for metadata and automatic chapter splitting on headings.
Requirements
- Drupal 11.1+, PHP 8.3+ with `zip`, `dom`, and `libxml`
- andileco/php-epub (installed automatically via Composer)
- Book Integration submodule: the Book module
- Markdown submodule: `league/commonmark`
- Viewer submodule: the epub.js and JSZip JavaScript libraries (see below). Sites with a strict Content Security Policy need `frame-src blob:; child-src blob:`.
Installation
composer require drupal/epub_generator
drush en epub_generator epub_generator_book
Then configure defaults at Administration > Configuration > Content authoring > ePub Generator and map your book metadata fields under ePub Book Field Mapping.
The Viewer submodule needs two JavaScript libraries. Add them to the `repositories` section of your project's `composer.json`:
{
"type": "package",
"package": {
"name": "futurepress/epubjs",
"version": "0.3.93",
"type": "drupal-library",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/epubjs/-/epubjs-0.3.93.tgz"
}
}
},
{
"type": "package",
"package": {
"name": "stuk/jszip",
"version": "3.10.1",
"type": "drupal-library",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz"
}
}
}
Then:
composer require futurepress/epubjs:0.3.93 stuk/jszip:3.10.1
drush en epub_generator_viewer
AI Acknowledgement
AI was instrumental in the development of this module, but I reviewed and tested it thoroughly.
Project information
- Project categories: Content display, Import and export
- Created by andileco on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
