Metadata-Version: 2.4
Name: ozaru
Version: 0.14.2
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Text Processing
Classifier: Topic :: Multimedia :: Graphics :: Viewers
Classifier: Topic :: Office/Business
Classifier: Typing :: Typed
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Summary: Read, draw, edit and protect PDF files from Python. Small API, Rust core, no dependencies.
Keywords: pdf,pdf-reader,text-extraction,pdf-forms,pdf-rendering,pdf-encryption,rust
Author: Jair Estupiñan
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://jair-dev57.github.io/ozaru/changelog/
Project-URL: Documentation, https://jair-dev57.github.io/ozaru/
Project-URL: Issues, https://github.com/Jair-dev57/ozaru/issues
Project-URL: Repository, https://github.com/Jair-dev57/ozaru

<p align="center">
  <img src="https://raw.githubusercontent.com/Jair-dev57/ozaru/main/assets/gorilla.png" alt="" width="170">
  &nbsp;&nbsp;
  <img src="https://raw.githubusercontent.com/Jair-dev57/ozaru/main/assets/ozaru-wordmark.svg" alt="Ozaru" height="78">
</p>

<p align="center"><strong>Read, analyze, draw, convert, edit and protect PDF files from Python.<br>
Small API, Rust core, no dependencies.</strong></p>

<p align="center">
  <a href="https://pypi.org/project/ozaru/"><img alt="PyPI" src="https://img.shields.io/pypi/v/ozaru?color=F47B20"></a>
  <a href="https://pypi.org/project/ozaru/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/ozaru"></a>
  <a href="https://github.com/Jair-dev57/ozaru/actions/workflows/CI.yml"><img alt="CI" src="https://github.com/Jair-dev57/ozaru/actions/workflows/CI.yml/badge.svg"></a>
  <a href="https://github.com/Jair-dev57/ozaru/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/pypi/l/ozaru"></a>
</p>

<p align="center">
  <a href="https://jair-dev57.github.io/ozaru/">Documentation</a> ·
  <a href="https://pypi.org/project/ozaru/">PyPI</a> ·
  <a href="https://jair-dev57.github.io/ozaru/changelog/">Changelog</a>
</p>

---

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Jair-dev57/ozaru/main/assets/speed-dark.svg">
    <img alt="Time to extract text and draw pages: ozaru against PyMuPDF and pypdf, shorter is better" src="https://raw.githubusercontent.com/Jair-dev57/ozaru/main/assets/speed-light.svg" width="760">
  </picture>
</p>

<p align="center"><sub>Median time of one call, on an Intel Core i5-11400H.
<a href="https://jair-dev57.github.io/ozaru/reference/speed/">All the numbers</a>.</sub></p>

```python
import ozaru

# The text, in reading order, and the tables as rows or Markdown
text = ozaru.extract_text("invoice.pdf")
tables = ozaru.extract_tables("report.pdf")

# Every page as a picture, on every core; pictures into a PDF
ozaru.render_pages("catalog.pdf", "pages", format="jpeg")
ozaru.images_to_pdf(["scan.tif", "photo.jpg"], "out.pdf")

# A text taken out of the file for good, not just covered
ozaru.redact_text("contract.pdf", "safe.pdf", "ID 1234567")

# What changed between two versions
print(ozaru.compare("v1.pdf", "v2.pdf").summary())
```

## What it does

- **Read** the text in reading order, words and lines with their boxes, fonts and colors, and search with positions.
- **Analyze** tables, headings, regions, and the whole document as Markdown for language models.
- **Convert** pages to PNG, JPEG, BMP, PNM or TIFF, and pictures (JPEG, PNG, BMP, GIF, TIFF, JPEG 2000) to PDF.
- **Organize** pages: merge, split, insert, replace, move, rotate, crop and delete.
- **Edit** with text, shapes, pictures, watermarks, highlights, notes and links; fill, create and flatten forms.
- **Protect** with real redaction, sanitizing and passwords; **compare** two versions of a PDF.
- **Shrink** a PDF without loss: compressed object streams, streams compressed again, duplicates kept once, page content cleaned, pictures written smaller; and, if asked, pictures with fewer pixels or as JPEG.

Every function has a command too: `uvx ozaru markdown report.pdf`, `uvx ozaru compare v1.pdf v2.pdf`, and more.

| | **ozaru** | PyMuPDF | pypdf |
|---|---|---|---|
| **License** | MIT | AGPL or paid | BSD |
| **Engine** | Rust, no dependencies, fuzzed in CI | C (MuPDF) | pure Python |
| **Draws pages** | yes | yes | no |
| **Images** | own readers and writers | MuPDF's | needs Pillow |
| **Compare PDFs** | built in | no | no |

Young and moving fast: the [road to 1.0.0](https://github.com/Jair-dev57/ozaru/blob/main/design/engine.md)
is to do everything PyMuPDF and pypdf do, and more.

## Installation

With [uv](https://docs.astral.sh/uv/), in your project:

```bash
uv add ozaru
```

From the terminal, with nothing installed:

```bash
uvx ozaru text invoice.pdf
```

Or into the active environment: `uv pip install ozaru`. It also installs with `pip`.
Python 3.10 or newer; wheels for Linux, macOS and Windows, so no Rust needed.

## Contributing

You need [Rust](https://rustup.rs/) and [uv](https://docs.astral.sh/uv/). Then run:

```bash
git clone https://github.com/Jair-dev57/ozaru.git
cd ozaru
uv run pytest
```

See the [contributing guide](https://jair-dev57.github.io/ozaru/contributing/).
Bug reports and ideas are welcome in the
[issue tracker](https://github.com/Jair-dev57/ozaru/issues); for security problems,
read [SECURITY.md](https://github.com/Jair-dev57/ozaru/blob/main/SECURITY.md).

## License

ozaru is released under the
[MIT License](https://github.com/Jair-dev57/ozaru/blob/main/LICENSE).

