Python bindings for the pure-Rust office2pdf converter
Project description
office2pdf-python
Python bindings for office2pdf, a pure-Rust converter for DOCX, PPTX, and XLSX documents to PDF.
The package distribution is named office2pdf-python; the import package is office2pdf.
Install
python -m pip install office2pdf-python
Supported Python versions are 3.10 through 3.14. Wheels use PyO3 abi3-py310, so one wheel can support all compatible CPython versions for the same platform. CI targets Linux, macOS, and Windows.
Usage
from pathlib import Path
from office2pdf import ConvertOptions, Format, convert_bytes, convert_path
result = convert_path("report.docx")
Path("report.pdf").write_bytes(result.pdf)
options = ConvertOptions(paper_size="a4", landscape=False, include_warnings=True)
data = Path("slides.pptx").read_bytes()
result = convert_bytes(data, Format.PPTX, options)
Path("slides.pdf").write_bytes(result.pdf)
CLI
The package also installs an office2pdf command:
office2pdf input.docx output.pdf
The CLI accepts DOCX, PPTX, and XLSX input paths and writes the converted PDF bytes to the output path.
API
Format
Enum values: Format.DOCX, Format.PPTX, and Format.XLSX.
ConvertOptions
Dataclass fields:
page_range: str | None— rejected when set becauseoffice2pdf 0.6.0does not expose a native field for it.sheet_filter: Sequence[str] | None— maps to upstreamsheet_namesfor XLSX conversion.slide_range: str | None— accepts upstream strings like"1-5"or"3".paper_size: str | None— accepts upstream"a4","letter", or"legal".landscape: bool | None— maps to upstream orientation control.font_paths: Sequence[str | pathlib.Path]— additional font directories.pdf_standard: str | None— currently supports"pdf/a-2b".include_warnings: bool— controls whether returned warnings are included inConversionResult.memory_limit_mb: int | None— rejected when set becauseoffice2pdf 0.6.0does not expose a native field for it.streaming: bool— enables upstream streaming mode for supported formats.
ConversionResult
Dataclass fields:
pdf: byteswarnings: tuple[str, ...]metrics: Mapping[str, Any] | None
Functions
convert_bytes(data: bytes | bytearray | memoryview, format: Format | str, options: ConvertOptions | None = None) -> ConversionResult
convert_path(path: str | pathlib.Path, options: ConvertOptions | None = None) -> ConversionResult
infer_format(path: str | pathlib.Path) -> Format
convert_path() validates the file extension before calling the native extension. convert_bytes() requires an explicit format.
Local development
Install Rust and Python 3.10 or newer. For local development, create and activate a virtual environment before running maturin develop:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip maturin pytest
maturin develop --locked
python -m pytest
cargo fmt --check
cargo clippy --all-targets -- -D warnings
Build artifacts:
maturin build --locked --release --compatibility pypi
maturin sdist
No LibreOffice, Docker, Chromium, or external system service is required by this binding. Conversion behavior comes from the upstream pure-Rust crate.
CI
The CI workflow runs tests on ubuntu-latest, macos-latest, and windows-2022 for Python 3.10, 3.11, 3.12, 3.13, and 3.14. It builds and installs the extension as an editable package, runs pytest, and performs an import smoke test.
Release-style wheel building is checked once in a dedicated wheel smoke job. Full Linux, macOS, and Windows release wheels are built by the release workflow instead of every CI matrix job. Rust fmt and clippy run in a separate Ubuntu lint job.
Release
The release workflow runs on v* tags or manual dispatch. It builds Linux, macOS, and Windows wheels plus an sdist, then publishes with PyPI Trusted Publishing using GitHub OIDC (id-token: write). No PyPI API token is required.
Before the first publish, configure PyPI with a pending trusted publisher:
- PyPI project name:
office2pdf-python - Owner:
agentsyaml - Repository:
office2pdf-python - Workflow:
release.yml - Environment:
pypi
Create a matching GitHub environment named pypi and require manual approval for safer first releases. A pending trusted publisher can create the PyPI project on first use, but it does not reserve the project name before that first publish.
To publish a release automatically, update the version in pyproject.toml and Cargo.toml, commit the change, then push a matching tag:
git tag v0.1.0
git push origin v0.1.0
The tag push starts .github/workflows/release.yml, builds artifacts, publishes to PyPI after the pypi environment approval, and creates a GitHub Release for tag-triggered runs.
Upstream dependency
This package wraps office2pdf = "0.6" from crates.io. The upstream project is Apache-2.0 licensed and hosted at https://github.com/developer0hye/office2pdf.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file office2pdf_python-0.1.0.tar.gz.
File metadata
- Download URL: office2pdf_python-0.1.0.tar.gz
- Upload date:
- Size: 41.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c0b73a3e45d2aa2f9202024d029a56c6b691657b0b134d5178b4870d549348
|
|
| MD5 |
6dbfba5543bcddaf77318f68ee7fa0bd
|
|
| BLAKE2b-256 |
8a62bf89f6d9fb7f33917396dbea543f10b8e669778c9d6a4162321a8f449d03
|
Provenance
The following attestation bundles were made for office2pdf_python-0.1.0.tar.gz:
Publisher:
release.yml on agentsyaml/office2pdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
office2pdf_python-0.1.0.tar.gz -
Subject digest:
64c0b73a3e45d2aa2f9202024d029a56c6b691657b0b134d5178b4870d549348 - Sigstore transparency entry: 1738654389
- Sigstore integration time:
-
Permalink:
agentsyaml/office2pdf-python@a6805db4148f77ff883a8ea3e240b9f61506695c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/agentsyaml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6805db4148f77ff883a8ea3e240b9f61506695c -
Trigger Event:
push
-
Statement type:
File details
Details for the file office2pdf_python-0.1.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: office2pdf_python-0.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 25.7 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21fa8a3f207568895d124e7f292fdbd29d5ad8ab48fc9e5a699e7ac81bea020
|
|
| MD5 |
abd88f7af49af9baafc155a95c42b804
|
|
| BLAKE2b-256 |
4855f15cef9b24d67144518a07f1383360b2a838bfa3c21b9de163f69018bff3
|
Provenance
The following attestation bundles were made for office2pdf_python-0.1.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on agentsyaml/office2pdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
office2pdf_python-0.1.0-cp310-abi3-win_amd64.whl -
Subject digest:
d21fa8a3f207568895d124e7f292fdbd29d5ad8ab48fc9e5a699e7ac81bea020 - Sigstore transparency entry: 1738654493
- Sigstore integration time:
-
Permalink:
agentsyaml/office2pdf-python@a6805db4148f77ff883a8ea3e240b9f61506695c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/agentsyaml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6805db4148f77ff883a8ea3e240b9f61506695c -
Trigger Event:
push
-
Statement type:
File details
Details for the file office2pdf_python-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: office2pdf_python-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 28.0 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1128d50d5c4d660dc8b5d11e6880157252fc747add8d9b406d06ec075ee0e627
|
|
| MD5 |
da68d9ea5b88d84adb623f8d70813623
|
|
| BLAKE2b-256 |
6b382e45c9d4f5cc087fac0f2c760bc769861089e85eb657c5eace44c2c11591
|
Provenance
The following attestation bundles were made for office2pdf_python-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on agentsyaml/office2pdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
office2pdf_python-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
1128d50d5c4d660dc8b5d11e6880157252fc747add8d9b406d06ec075ee0e627 - Sigstore transparency entry: 1738654428
- Sigstore integration time:
-
Permalink:
agentsyaml/office2pdf-python@a6805db4148f77ff883a8ea3e240b9f61506695c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/agentsyaml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6805db4148f77ff883a8ea3e240b9f61506695c -
Trigger Event:
push
-
Statement type:
File details
Details for the file office2pdf_python-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: office2pdf_python-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5692accf2e92c5a2c2eeb17a0ce082537bcdd996295bcd507fe024a56de9365
|
|
| MD5 |
b6127bf30d8d8924cd83897b49930fa0
|
|
| BLAKE2b-256 |
fe3dde6b7b7c3a9171b52bb7fd8501a0568c821d1306e5d7092ad6714e87e7a6
|
Provenance
The following attestation bundles were made for office2pdf_python-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on agentsyaml/office2pdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
office2pdf_python-0.1.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
d5692accf2e92c5a2c2eeb17a0ce082537bcdd996295bcd507fe024a56de9365 - Sigstore transparency entry: 1738654460
- Sigstore integration time:
-
Permalink:
agentsyaml/office2pdf-python@a6805db4148f77ff883a8ea3e240b9f61506695c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/agentsyaml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6805db4148f77ff883a8ea3e240b9f61506695c -
Trigger Event:
push
-
Statement type: