Skip to main content

ozaru

Read PDF files from Python with a small, simple API and a Rust core.

PyPI version Python versions CI License: MIT

Documentation: https://jair-dev57.github.io/ozaru/

import ozaru

text = ozaru.extract_text("invoice.pdf")
pages = ozaru.page_count("invoice.pdf")
info = ozaru.metadata("invoice.pdf")

print(f"{info.title}: {pages} pages")
print(text)

Why ozaru?

  • One line per task. Pass a path and get the result. There are no objects to manage.
  • Easy to install. Prebuilt wheels mean you don't need Rust or a compiler.
  • No Python dependencies. ozaru installs nothing else into your environment.
  • Built on Rust. Pages are counted by OZARU ENGINE, ozaru's own PDF engine, and text is extracted by pdf_oxide until the engine takes over.
  • Typed. Type hints are included, so your editor can autocomplete and check your calls.

Installation

pip install ozaru

Or, with uv:

uv add ozaru

ozaru requires Python 3.10 or newer.

Usage

Extract text

extract_text returns the text of the whole document as a single string:

import ozaru

text = ozaru.extract_text("report.pdf")

Count pages

page_count returns the number of pages as an integer:

import ozaru

pages = ozaru.page_count("report.pdf")

Handle errors

import ozaru

try:
    text = ozaru.extract_text("report.pdf")
except FileNotFoundError:
    print("The file does not exist.")
except OSError:
    print("The file could not be read.")
except ValueError:
    print("The file could not be read as a PDF.")

Damaged pages

If a page can't be read, extract_text still returns the other pages, leaves that page empty and emits an ozaru.PageWarning with its page number:

import warnings

import ozaru

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always", ozaru.PageWarning)
    text = ozaru.extract_text("report.pdf")

for warning in caught:
    print(f"Page {warning.message.page} could not be read")

API

Function Returns Raises Warns
extract_text(path) str OSError, ValueError PageWarning
page_count(path) int OSError, ValueError
metadata(path) Metadata OSError, ValueError
page_info(path) list[PageInfo] OSError, ValueError PageWarning

Metadata has the title, author, subject, keywords, creator and producer of the PDF as str, and its creation_date and modification_date as datetime. Each one is None when the PDF doesn't have it.

PageInfo has the number, width, height and rotation of a page, with width and height in points as a viewer shows it, rotated.

Every function takes an optional password keyword argument, the user or owner password of a protected PDF. A missing or wrong password raises ozaru.PasswordError, a subclass of ValueError.

File problems raise the same OSError subclasses as Python's open(), such as FileNotFoundError, PermissionError and IsADirectoryError.

path can be a str or a pathlib.Path.

Supported platforms

Prebuilt wheels are available for CPython 3.10 and newer:

Operating system Architectures
Linux (glibc) x86_64, aarch64
Linux (musl) x86_64, aarch64
macOS Intel, Apple Silicon
Windows x64

Before each release, the tests run against the wheels of glibc Linux, macOS and Windows on their own platform, with Python 3.10 and 3.14 (only 3.10 on Apple Silicon).

On other platforms, pip builds ozaru from source, which requires a Rust toolchain.

Limitations

ozaru is in early development, so its API may change between releases.

  • It reads the text stored in a PDF and does not perform OCR, so scanned documents may return little or no text.

Contributing

You need Rust and uv. Then run:

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

See the contributing guide. Bug reports and ideas are welcome in the issue tracker.

License

ozaru is released under the MIT License.

Metadata

Release files for ozaru 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ozaru 0.2.4
File Size Uploaded Provenance Actions
ozaru-0.2.4.tar.gz 170.5 kB Without provenance Details for ozaru-0.2.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ozaru 0.2.4
File Actions
ozaru-0.2.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for ozaru-0.2.4-cp310-abi3-win_amd64.whl
ozaru-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for ozaru-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl
ozaru-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for ozaru-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl
ozaru-0.2.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for ozaru-0.2.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ozaru-0.2.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for ozaru-0.2.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ozaru-0.2.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for ozaru-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
ozaru-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for ozaru-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 60.8 MB

Release files / ozaru-0.2.4.tar.gz

Download URL ozaru-0.2.4.tar.gz
Size 170.5 kB
Tags Source
SHA-256 checksum
How to use checksums
84a0a17a1640686e3fd2186c08f4a18554cdf4efe6dbebd64a78d38d83f07ac0
BLAKE2b-256 checksum
How to use checksums
a37afd5c5c1c6d580cc589d90a000fa7f2c4c5d2a00b99f54b85ef76865ce21a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-win_amd64.whl

Download URL ozaru-0.2.4-cp310-abi3-win_amd64.whl
Size 8.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4a9575361bd6b1a402b9f8f376d938095eb8f438db292e59563df797aa6aeaab
BLAKE2b-256 checksum
How to use checksums
4a0a118a7bfeecfb8c00c335eb8573b3cb490d06a03140adba6133064b741257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL ozaru-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl
Size 9.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
12d38d486f60083b62582b3dd33a910b5ab665a79462ccd8d5b6322c11281267
BLAKE2b-256 checksum
How to use checksums
7449b180d49c39fdb6757e7dc7e87eaf1e21a84e4ea84013b91ca6a129619a32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL ozaru-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl
Size 8.9 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d28d2ce24564319465bac7a0fc7fbd6a1ce78a87e36edbc7f5e2fa06f458602f
BLAKE2b-256 checksum
How to use checksums
f9e355a534f0ae9e5f86246c3f7470cdb7a3b98203221986afbf572e9f6547c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ozaru-0.2.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 8.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f3467219aff02cc7c33c1d8a45bd72da2c1475bed3b99e89a25ba113566b12ed
BLAKE2b-256 checksum
How to use checksums
170ee849c14408e47a140eb08eb38e295b57f877b254cc11b2f67297fc54177e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ozaru-0.2.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 8.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e1a880cbb8104f127348c2974eff48f63f9800336ad35e24a8fc370f376e47c8
BLAKE2b-256 checksum
How to use checksums
2c9c7e37e703d9bf9b94170ef2e0fb596b5654749f1306c64cde3fbdbedeaf8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL ozaru-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Size 8.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d08872f4de4e7e57f74f0b829c38d8bb7c2ea723abb57e05d80b8d9d2049efda
BLAKE2b-256 checksum
How to use checksums
65275e5264844809d8ef1157f1e0570823849dea365aa2d6df79eec0734ae2e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ozaru-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ozaru-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
Size 8.4 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
541f78d30bdf3faf886607fdcf43e9ac762606747c99cac728e02801ebabb69d
BLAKE2b-256 checksum
How to use checksums
6cd41c0fc0cb503739787258c448cd7e8ae3edcbc2f2fb89b6755045ffc16b43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ozaru 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.4 This release

8 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page