EPUB PDF wrap
Converts a PDF into an EPUB by rendering and wrapping each page of the PDF in an EPUB page. This is specifically aimed at PDF files that cannot be converted into EPUB any other way without corrupting their visual rendering (comics, scientific papers...).
The generated EPUB uses EPUB 3 fixed-layout metadata by default: each PDF page is one pre-paginated spine item.
Installation
pip install epub-pdf-wrap
From source (with dev dependencies for testing):
pip install -e ".[dev]"
Usage
epub-pdf-wrap <pdf-filename> [options]
By default the output filename is the input filename with the pdf extension
replaced by the epub extension. Running without pip install also works via
python -m epub_pdf_wrap.
Options
-r <num>, --resolution <num>: target render width in pixels for the pages in the output file. By default the pages are rendered at the resolution the PDF itself declares.--margin <pixels>: add a uniform margin to every side of each rendered page. The value must be an integer greater than or equal to zero.--margins <top> <right> <bottom> <left>: add a separate margin to each side of every rendered page. Values are output pixels and must be integers greater than or equal to zero.-c, --crop-global: trim the white margins around the page content using one common inset for all pages (safe: never clips content on any page, all pages keep the same size).--crop-page: trim the white margins around each page's own content, page by page (trims more aggressively but page sizes may vary).--transparent-background: preserve unpainted PDF page areas as transparent PNG pixels. By default they are rendered white for consistent display across reader themes.--nocover: skip using the first page as the book's cover image. By default the first page of the PDF is also set as the EPUB cover.--epub2: generate EPUB 2 output for older readers. The default is EPUB 3 fixed-layout output.
-c/--crop-global and --crop-page are mutually exclusive; with neither
flag the margins are left as-is.
--margin and --margins are mutually exclusive. Added margins are applied
after cropping and scaling, so their sizes are exact output pixel counts.
Metadata
Document metadata (title, author, subject, keywords and creation date) is taken from the PDF and written into the EPUB. Empty fields are omitted; the title falls back to the input filename if the PDF has none.
Examples
Convert a paper at a wider resolution and name the output explicitly:
epub-pdf-wrap paper.pdf -o paper.epub -r 1400
Add 20 pixels around every side, or use different values for each side:
epub-pdf-wrap comic.pdf --margin 20
epub-pdf-wrap comic.pdf --margins 10 20 30 40
Development
python -m venv .venv
.venv\Scripts\activate # Windows (or `source .venv/bin/activate` elsewhere)
pip install -e ".[dev]"
pytest
samples/ contains real input PDFs for manually verifying the output.
License
Distributed under the BSD 3-Clause License; see LICENSE.
Copyright (c) 2026, Andrea Esuli (andrea@esuli.it).
Release files for epub-pdf-wrap 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| epub_pdf_wrap-0.1.2.tar.gz | 18.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| epub_pdf_wrap-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.4 kB
Release files / epub_pdf_wrap-0.1.2.tar.gz
| Download URL | epub_pdf_wrap-0.1.2.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bf091a1dfc38952666b0a7da15b90deda24e7ac44877e3ac89cd006ca5a9c82
|
|
BLAKE2b-256 checksum How to use checksums |
6b6931bfc7306977588053143245dc6cc47c2a1e672d7e615d7c0678fec3c5be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / epub_pdf_wrap-0.1.2-py3-none-any.whl
| Download URL | epub_pdf_wrap-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
093ba59b68a5533d9587b429e0bcbb429dba35599c9fad2c25a031f021f1e02a
|
|
BLAKE2b-256 checksum How to use checksums |
06b455370d347eab417b1212bd3237632053254e3361cf896a92579ba141bd22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|