kakemono 0.24.3

Convert PDF, Word, Excel, PowerPoint and EPUB documents and web pages to HTML, Markdown, EPUB, LaTeX and JSON in Rust
Documentation
<div align="center">

<img src="docs/assets/logo.svg" alt="kakemono logo" width="120" height="120">

# kakemono

**Convert PDF papers and books, Word documents, Excel workbooks, PowerPoint decks, EPUB books, web pages, or arXiv papers into readable, editable formats.**

[![Release](https://img.shields.io/github/v/release/iamcaominhtien/kakemono?label=release&color=d9822b)](https://github.com/iamcaominhtien/kakemono/releases/latest)
[![CI](https://img.shields.io/github/actions/workflow/status/iamcaominhtien/kakemono/ci.yml?branch=main&label=CI&logo=githubactions&logoColor=white)](https://github.com/iamcaominhtien/kakemono/actions/workflows/ci.yml)
[![crates.io](https://img.shields.io/crates/v/kakemono?logo=rust&logoColor=white)](https://crates.io/crates/kakemono)
[![PyPI](https://img.shields.io/pypi/v/kakemono?logo=python&logoColor=white)](https://pypi.org/project/kakemono/)
[![docs.rs](https://img.shields.io/docsrs/kakemono?label=docs.rs)](https://docs.rs/kakemono)
[![Docs](https://img.shields.io/badge/docs-site-b5481c)](https://iamcaominhtien.github.io/kakemono/)
[![License: MIT](https://img.shields.io/badge/license-MIT-2f9e44)](LICENSE)

</div>

kakemono is a Rust document converter and library. It extracts reading order and structure from PDFs, Word files, Excel workbooks, PowerPoint decks, EPUB books and web pages, including headings, tables, equations and figures. It can produce HTML, DOCX, Markdown, LaTeX, Typst (an article or a printed book), EPUB, editable JSON and JSONL chunks for retrieval. Word, EPUB and web page input can also be laid out as PDF, a workbook printed as Excel prints it, and a deck's slides drawn as PowerPoint draws them. PDF processing uses [hayro](https://github.com/LaurenzV/hayro); no Python, Poppler or MuPDF is needed for the CLI.

## Install

Download a prebuilt binary for Linux, macOS or Windows from the [latest release](https://github.com/iamcaominhtien/kakemono/releases/latest), or install with stable Rust:

```bash
cargo install kakemono
```

To build from a checkout, run `cargo build --release`. For Python, use `pip install kakemono` and see the [Python guide](python/README.md). For JavaScript and TypeScript (`@kakemono/node`, `@kakemono/wasm`), Java and Kotlin (`io.github.iamcaominhtien:kakemono`, with a LangChain4j parser) and .NET (`Kakemono`), see [the bindings](docs/BINDINGS.md).

## Quick start

```bash
kakemono convert paper.pdf                   # paper.friendly.html
kakemono convert 1706.03762 -o paper.md      # arXiv ID → Markdown
kakemono convert report.docx -o report.pdf   # Word → PDF
kakemono convert sales.xlsx -o sales.md      # Excel → Markdown, a table per region of each sheet
kakemono convert sales.xlsx -o sales.pdf     # Excel → PDF, printed as Excel prints it
kakemono convert talk.pptx -o talk.md        # PowerPoint → Markdown, a section per slide, notes after it
kakemono convert talk.pptx -o talk.pdf       # PowerPoint → PDF, the slides as PowerPoint draws them
kakemono convert book.epub -o book.md        # EPUB → Markdown
kakemono convert https://en.wikipedia.org/wiki/Fourier_transform -o ft.md   # web page → Markdown
kakemono convert saved-page.html -o page.docx # HTML file → Word
kakemono convert paper.pdf -o paper.epub
kakemono convert book.pdf -o book.typ        # Typst; then `typst compile book.typ`
kakemono convert paper.pdf -o paper.jsonl    # chunks for retrieval
```

Input can be a local PDF, `.docx`, `.doc`, `.xlsx`, `.pptx`, `.epub` or `.html`, an arXiv ID or an arXiv URL, or the `http(s)` address of a web page (its article is kept, without menus, sidebars or advertisements, and its pictures are fetched; see [web pages](docs/guide/input-web.md)). The output extension selects the format; use `--format` to choose explicitly. arXiv downloads are cached in `~/.cache/kakemono` (override with `KAKEMONO_CACHE`).

For HTML, choose a layout with `--mode`:

| Mode | Layout |
| --- | --- |
| `friendly` | Responsive single-column article (default) |
| `medium` | Preserves pages and columns while reflowing text |
| `hard-95` | Page-like layout with visible HTML text |
| `hard` | Page images with a selectable text layer |

```bash
kakemono convert paper.pdf -m hard-95 -o paper.html
kakemono convert paper.pdf --all -o out/     # all four HTML modes
kakemono convert paper.pdf -o paper.md --image-dir images
kakemono convert paper.pdf -o paper.jsonl --chunk-tokens 512
```

Markdown, LaTeX, Typst and JSON write image files alongside the output by default. The Typst output is laid out as a printed book (title page, chapters on right-hand pages, running heads, footnotes on the page of their call) when the document has chapters, as an article otherwise (`--layout` to choose); its settings, such as the page size and the fonts, are at the top of the `.typ` file. See the [guide](docs/guide/output-typst.md). See `kakemono convert --help` for image handling, table and equation options, tokenizers and other settings. `kakemono inspect paper.pdf` prints the detected structure; `kakemono fetch <arxiv-id> -o paper.pdf` downloads a paper.

## Edit extracted content

Export editable JSON, change its text, then apply it to the same input:

```bash
kakemono convert paper.pdf -o paper.json
# Edit paper.json and save it as paper.edited.json
kakemono convert paper.pdf --content paper.edited.json -o paper.edited.md
```

This JSON is distinct from the full analysis written by `--json`. Edited text is supported in PDF-derived outputs except `hard`; for Word and PowerPoint input it does not reach page-layout outputs (PDF, `hard`, `hard-95` or `medium`). See the [editable JSON guide](docs/guide/json.md) for its schema and editing rules.

## Libraries

Rust: add the crate with `cargo add kakemono`, then reuse an analysis across outputs:

```rust
use kakemono::{HtmlOptions, Mode, Paper};

let paper = Paper::from_bytes(std::fs::read("paper.pdf")?)?;
let analysis = paper.analyze();
let out = paper.to_html(&analysis, &HtmlOptions { mode: Mode::Friendly, ..Default::default() });
std::fs::write("paper.html", out.html)?;
```

Any of this can be stopped from another thread, or after a time limit, with a `CancelToken`:
`token.run(|| paper.analyze())` returns `Err(Cancelled)` soon after `token.cancel()`, normally
within a page. The [API reference](https://docs.rs/kakemono) and [library guide](docs/guide/library.md) cover other outputs. Python bindings and examples are documented in [python/README.md](python/README.md); Node.js, WebAssembly, the JVM, .NET and C in [docs/BINDINGS.md](docs/BINDINGS.md).

## Limitations

Scanned and encrypted PDFs are not supported. Complex tables and equations may be kept as images, and unusual layouts can affect reading order. Word 6/95, RTF and password-protected Word files are not supported, nor are PowerPoint 97–2003 (`.ppt`) files, EPUB books protected by DRM, nor web pages built by scripts in the browser or behind a login. See the [full limitations](docs/guide/limitations.md), the [Word input guide](docs/WORD-INPUT.md), the [Excel input guide](docs/EXCEL-INPUT.md), the [PowerPoint input guide](docs/POWERPOINT-INPUT.md), [EPUB input](docs/guide/input-epub.md) and [web pages](docs/guide/input-web.md).

## Development

```bash
cargo test --release
```

Some real-paper tests require additional downloads; see the [testing guide](docs/guide/testing.md). [CONTRIBUTING.md](CONTRIBUTING.md) explains the development workflow, and [ARCHITECTURE.md](ARCHITECTURE.md) describes the pipeline. See also the [documentation site](https://iamcaominhtien.github.io/kakemono/), the [detailed guide](docs/GUIDE.md), [benchmarks](docs/guide/performance.md) and [changelog](CHANGELOG.md).

## License

[MIT](LICENSE) © Cao Minh Tiến.