DEV Community

Cover image for πŸ“˜ Convert EPUB to PDF in Node.js Using Calibre (CLI + API)
Suraj Sutar
Suraj Sutar

Posted on

πŸ“˜ Convert EPUB to PDF in Node.js Using Calibre (CLI + API)

If you work with ebooks, documentation, or publishing pipelines, converting EPUB to PDF is a common requirement.

In this post, I’ll show you how to convert EPUB files to PDF using Calibre via a Node.js CLI and API that works on Linux, macOS, and Windows.

πŸš€ Introducing epub-to-pdf-cli

epub-to-pdf-cli is a lightweight Node.js tool that wraps Calibre’s powerful ebook-convert command and exposes it as:

βœ… A command-line tool

βœ… A Node.js programmatic API

βœ… Cross-platform utility (no bundled binaries)

πŸ”— npm: https://www.npmjs.com/package/epub-to-pdf-cli

πŸ”— GitHub: https://github.com/surajsutar7/epub-to-pdf-cli

✨ Features

*Convert EPUB β†’ PDF using Calibre
*

CLI + JavaScript API

Works on Linux, macOS, and Windows

No native bindings

Clear error handling

Ideal for automation & CI pipelines

πŸ“¦ Installation
Global CLI install
npm install -g epub-to-pdf-cli

Or run without installing
npx epub-to-pdf-cli book.epub

πŸ–₯ CLI Usage
epub2pdf [output.pdf]

Examples
epub2pdf mybook.epub
epub2pdf mybook.epub mybook.pdf

πŸ“š Programmatic Usage (Node.js)

Install locally:
npm install epub-to-pdf-cli

Use in your code:
import { convertEpubToPdf } from 'epub-to-pdf-cli';

await convertEpubToPdf('book.epub', 'book.pdf');

βš™ Requirements

This tool requires Calibre to be installed.

Verify installation:
ebook-convert --version

Install Calibre
Ubuntu / Debian
sudo apt install calibre

macOS
brew install calibre

Windows

Download from:
πŸ‘‰ https://calibre-ebook.com/download

❌ Common Errors & Fixes
ebook-convert: not found

➑️ Calibre is not installed or not in PATH.

EPUB file does not exist

➑️ Check input file path and permissions.

🧠 Why Not Use a Pure JS Converter?

EPUB β†’ PDF is complex:

Layout

Fonts

Pagination

CSS rendering

Calibre already solves these problems reliably.
This package simply gives you safe, scriptable access from Node.js.

πŸ“¦ Versioning & Stability

This project follows Semantic Versioning using Conventional Commits:

Commit Type Version
fix: Patch
feat: Minor
feat!: Major

Example:
git commit -m "feat!: change CLI input format"

πŸ›  Ideal Use Cases

Ebook automation pipelines

Backend services

Batch conversions

Publishing workflows

CI/CD ebook processing

πŸ“„ License

MIT Β© Suraj Sutar

⭐ Final Thoughts

If you need a reliable EPUB β†’ PDF solution in Node.js without reinventing the wheel, this tool keeps things simple and production-ready.

⭐ Star the repo if you find it useful
πŸ› Issues and PRs are welcome

Top comments (0)