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")

print(f"{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. The PDF work is done by pdf_oxide.
  • 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

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

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

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.1.6
File Size Uploaded Provenance Actions
ozaru-0.1.6.tar.gz 85.9 kB Without provenance Details for ozaru-0.1.6.tar.gz

Built distributions (wheels)

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

Total release size: 59.3 MB

Release files / ozaru-0.1.6.tar.gz

Download URL ozaru-0.1.6.tar.gz
Size 85.9 kB
Tags Source
SHA-256 checksum
How to use checksums
437eb8d933d454f201f8a369cae3307574582ae01bfef6ce24deea253eb3b363
BLAKE2b-256 checksum
How to use checksums
06831d068a165e00ae1abbbe25f3a20ce4dcbc465d95d46f2ec91792772b6bc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-win_amd64.whl

Download URL ozaru-0.1.6-cp310-abi3-win_amd64.whl
Size 7.9 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6fa57b49e5f3d12179b52c056ed5c40c3b9aa420d14245bcab7c9139040fab0c
BLAKE2b-256 checksum
How to use checksums
9a3d30d02147019406f8e90f0dd2f32e55f99b068deb31ca88f8add3ce6eb2e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL ozaru-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl
Size 9.1 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
5cd009b1d88ba4c8ba0060f5093a32b990929aaed741a1f857f742f54ce06df7
BLAKE2b-256 checksum
How to use checksums
033d8abe5d63f63d01f28b7d78939b758fa44c528a65e4d91d366bc14682a9d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL ozaru-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl
Size 8.7 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
700e04225dc465627a82b6491829db20ffc9d4622d7a5e3fd5812903c4bbe3a8
BLAKE2b-256 checksum
How to use checksums
1d1553cc4169b95386506d69f94bb5268d3d0269263cd42d06494a2d7ef1bb83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ozaru-0.1.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 8.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8bf18c3a4aedfe5ded4ca398d6df508365b035c55b8c1b37cbb013c8c1858fca
BLAKE2b-256 checksum
How to use checksums
422d857ccb231e0f9055677856416792c24540929a63f43be0ab59600aaabe98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ozaru-0.1.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 8.6 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2f2f5fd302fb3db7b9cb3726ebd5854dfa29cc7ab781fb6f3d599d00361fb7d1
BLAKE2b-256 checksum
How to use checksums
b9b15c039cf64421bbfb16925f26ce5e96b692518eb07b5c0ec1bc6ab5174a36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-macosx_11_0_arm64.whl

Download URL ozaru-0.1.6-cp310-abi3-macosx_11_0_arm64.whl
Size 7.9 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bdca9f8d1528e2c135f7db738bc4536a91feb67900b9d5068e4954d6b16b2ed2
BLAKE2b-256 checksum
How to use checksums
2bedef9b7b35f0c474d0fb77dc6d80d38af4236792ff8c17e68eb2b0c838cd55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ozaru-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl
Size 8.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
51038c4c806cfe12631323e6f599c6997dfb07060983d919252385314079cdae
BLAKE2b-256 checksum
How to use checksums
2e93c45af9fe353eaebc468ba9d14e2cd4eddb406da423333f159feb4db0e094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1.6

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.

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