Read, render, and extract text from DjVu files — Python bindings for the pure-Rust djvu-rs library
Actively maintained. Last release 11 days ago, commits in 22 of the last 26 weeks. A safe choice.
pip install djvu-rsdjvu-rs for Python
Read, render, convert, and edit DjVu files from Python. Bindings for the pure-Rust djvu-rs library: no DjVuLibre, no GPL, no system dependencies. Rendering and conversion release the GIL.
| Your task | How |
|---|---|
| Render a page to PIL / numpy | page.render(dpi=150).to_pil() / .to_numpy() — rendering |
| Extract text | page.text(), or page.text_layer() for words with coordinates |
| Convert DjVu → PDF, EPUB, CBZ, TIFF | doc.write_pdf(path) and friends — export |
| Build a viewer (previews, viewport crops) | page.render(quality='coarse'), page.render(region=(x, y, w, h)) |
| Edit metadata, bookmarks, links, text layer | djvu.Editor — editing |
| Create DjVu from images | Not in Python — use the djvu encode CLI or the Rust crate |
Install
pip install djvu-rs # or djvu-rs[numpy,pillow]
Wheels for CPython 3.9–3.13 on manylinux/musllinux, macOS, and Windows. The
package version matches the djvu-rs crate version.
Quick start
import djvu_rs as djvu
doc = djvu.Document.open('scan.djvu')
print(f'{doc.page_count()} pages')
page = doc.page(0)
print(f'{page.width}x{page.height} @ {page.dpi} dpi')
page.render(dpi=150).to_pil().save('page.png') # needs Pillow
text = page.text() # None if the page has no text layer
doc.write_pdf('scan.pdf') # selectable text, bookmarks, links
editor = djvu.Editor.open('scan.djvu')
editor.set_metadata({'title': 'Scan'})
editor.save('scan.djvu') # validated, atomic replace