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

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.

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.
  • It can't extract text from PDFs that need a password to open.

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.2

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.2
File Size Uploaded Provenance Actions
ozaru-0.2.2.tar.gz 165.4 kB Without provenance Details for ozaru-0.2.2.tar.gz

Built distributions (wheels)

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

Total release size: 60.6 MB

Release files / ozaru-0.2.2.tar.gz

Download URL ozaru-0.2.2.tar.gz
Size 165.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6fc90a06b9f048e5b2d3ffec9978f06b1ea81f553e754f0ebd9310225ca56e8f
BLAKE2b-256 checksum
How to use checksums
0072fb2dbfb547d79286ad99db0f7ac26b24e153c07bccb01344b367d0e5ea62
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.2-cp310-abi3-win_amd64.whl

Download URL ozaru-0.2.2-cp310-abi3-win_amd64.whl
Size 8.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
03be412f91fb9b2a030f403b0388b55588f4603bef85ee380b3c90e4dd079b8a
BLAKE2b-256 checksum
How to use checksums
7ec5e024eb13d8804ea8629fbb9d7ea067544f7ea4e24d61472b346e6faf8188
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.2-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL ozaru-0.2.2-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
390c2e883313309605475ab838c8cabe2936e60482aebda58e321ad2dc2b7b9b
BLAKE2b-256 checksum
How to use checksums
5d4a1099429f97d26675660e950728fe250a51ea2f51648a0a4b93b5c82d22eb
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.2-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL ozaru-0.2.2-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
031d58c3669fd3956a3449f43968a80b97faef16e25e9b29dae522d7fe0791c1
BLAKE2b-256 checksum
How to use checksums
debf597be1512cbbc928bc8e111b93ae74914ab13fa230e9b1159e8e9bd4d90a
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.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ozaru-0.2.2-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
8a836e161354df7d732a74b985fda7c59b83d8200d74742dc4bff40663e23d99
BLAKE2b-256 checksum
How to use checksums
5d02c7d71b3c3f0e4f8a527e7769b72a8435c8ceeac4353c5abfcf7218115b4f
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.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ozaru-0.2.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 8.7 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
300a4d0bdf218e33845ae88a1e400b13c1d60b0823e5c4b491ab4e9f5919baba
BLAKE2b-256 checksum
How to use checksums
048ea54dac515f4ec67f17f9e8a9aab5823cf793bb3833093101f34942d1c38c
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.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL ozaru-0.2.2-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
aa2bfef3425288ad2812e57b36c2406461a46c74bc6cc9e867bd358dcba3a8ae
BLAKE2b-256 checksum
How to use checksums
c7b1c4a4afffc6dc692461a526c1e9ab8acffd7fb9336120a9fd05b65fff023b
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.2-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ozaru-0.2.2-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
e0b4762d14c64583e41c44c299f834cd3a4766b40f5cc84bf16a298545cf74a4
BLAKE2b-256 checksum
How to use checksums
543361af30f0aed18ad74b73d85a4b3ecb2909920219cc0ec40ad5653375998d
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.2

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.2 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