Metadata-Version: 2.4
Name: ebook-converter-lib
Version: 1.2.1
Summary: Convert ebook between different formats
Author-email: bilec <martin.bilka826@gmail.com>
License-Expression: GPL-3.0-or-later
Project-URL: Repository, https://github.com/bilec/ebook-converter-lib
Classifier: Environment :: Console
Classifier: Intended Audience :: Other Audience
Classifier: Operating System :: POSIX :: Linux
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4>=4.9.3
Requires-Dist: css-parser>=1.0.6
Requires-Dist: html2text>=2020.1.16
Requires-Dist: lxml>=4.9.0
Requires-Dist: markdown>=3.0
Requires-Dist: odfpy>=1.4.1
Requires-Dist: pillow>=8.0.1
Requires-Dist: pypdf>=5.0.0
Requires-Dist: python-dateutil>=2.8.1
Requires-Dist: reportlab>=4.0
Requires-Dist: svglib==1.5.1
Dynamic: license-file

# ebook-converter-lib

`ebook-converter-lib` is a Python library and command-line tool for converting
ebooks between common formats. It is a modified fork of
[ebook-converter](https://github.com/gryf/ebook-converter) by gryf, which is
itself derived from the conversion components of
[Calibre](https://calibre-ebook.com/). Licensed under GPL-3.0-or-later.

## Install

```shell
python -m pip install ebook-converter-lib
```

Python 3.11 or newer is required. PDF conversion also requires Poppler tools
(`pdftohtml`, `pdfinfo`, and `pdftoppm`) available on `PATH`.

## Use as a library

```python
from ebook_converter_lib import convert

result = convert("book.docx", "book.epub")
if not result["success"]:
    raise RuntimeError(result["message"])
```

`convert()` returns a dictionary with `success` and `message` keys. Use
`check_deps_str()` to verify that conversion dependencies can load in an
embedded Python runtime.

### Options

Extra arguments use the command-line option format:

```python
convert("book.epub", "book.mobi", "--base-font-size", "12")
```

- `--remove-text`: one regular expression per line, every match is deleted.
  Escape special characters for literal text, e.g. `C\+\+`.
- Unknown options, stray values and invalid regular expressions fail the
  conversion.

## Command line

```shell
ebook-converter book.docx book.epub
```

## Supported formats

Input: `azw`, `azw3`, `docm`, `docx`, `epub`, `fb2`, `fbz`, `htm`, `html`,
`htmlz`, `lrf`, `markdown`, `md`, `mobi`, `odt`, `opf`, `pdb`, `pdf`, `pobi`,
`prc`, `rtf`, `shtm`, `shtml`, `text`, `textile`, `txt`, `txtz`, `updb`,
`xhtm`, `xhtml`.

Output: `azw3`, `docx`, `epub`, `fb2`, `html`, `htmlz`, `lrf`, `mobi`, `oeb`,
`txt`, `txtz`.

The output format is chosen from the output file extension.

## Development

```shell
uv sync --group dev
uv run pytest
```
