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; release wheels cover Linux (x86_64 and aarch64, glibc and musl), macOS (Intel and Apple Silicon), and Windows (x86_64).
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
Format identifies the input Office format for byte-based conversion:
Format.DOCX("docx")Format.PPTX("pptx")Format.XLSX("xlsx")
PdfStandard
PdfStandard currently supports pdf/a-2b:
- canonical:
PdfStandard.PDF_A_2B - compatibility alias:
PdfStandard.PDF_A_2_B
PdfStandard.from_value() accepts both forms and related normalizations ("pdf/a-2b", "pdfa2b").
XlsxUiScript
XlsxUiScript selects which Excel user-interface language an XLSX conversion reproduces when resolving theme fonts (<scheme val="minor"/>):
XlsxUiScript.HANGUL("hangul") — Korean UI Excel; upstream default.XlsxUiScript.LATIN("latin") — English, German, Danish, and other Latin-script Excel.
XlsxUiScript.from_value() accepts both names case-insensitively.
PaperSize
PaperSize.A4PaperSize.LETTERPaperSize.LEGAL
CustomPaperSize
CustomPaperSize(width: float, height: float) stores explicit PDF point dimensions, matching upstream PaperSize::Custom (1 point = 1/72 inch).
ConvertOptions
All options are stored in a Python dataclass and translated to native options via to_native().
-
sheet_names: Sequence[str] | None -
sheet_filter: Sequence[str] | NoneThese are aliases for XLSX sheet selection. If both are provided, they must be equal.
-
xlsx_ui_script: XlsxUiScript | str | NonePicks the theme face an XLSX scheme font resolves to.
Nonekeeps the upstream default (hangul). -
slide_range: SlideRange | str | NoneSlideRangesupports"1-5"parsing and also accepts explicitSlideRange(1, 5). Values are normalized tostart-endstrings for native conversion. -
include_hidden_slides: boolIncludes PPTX slides marked hidden. Defaults to
False, matching PowerPoint PDF export.slide_rangestill counts source slide ordinals. -
pdf_standard: PdfStandard | str | NoneOnly
pdf/a-2bis supported at this version. -
paper_size: PaperSize | CustomPaperSize | str | NoneString values normalize to named page sizes.
-
font_paths: Sequence[str | pathlib.Path] -
last_resort_font_family: str | NoneFamily appended to every generated font chain, so a caller-provided face can cover glyphs the document's own fonts cannot. Must be non-empty. Load the face itself through
font_paths. -
landscape: bool | None -
tagged: bool | None -
pdf_ua: bool | None -
streaming: bool -
streaming_chunk_size: int | None -
include_warnings: bool
Unsupported options are rejected to preserve API compatibility with upstream office2pdf 0.9.1:
page_range: str | Nonememory_limit_mb: int | None
ConversionResult
pdf: byteswarnings: tuple[ConvertWarning, ...]metrics: ConvertMetrics | Nonewarning_messages: tuple[str, ...]property collecting warning messages.
Warning types
Warning payloads from the native layer are mapped to typed subclasses of ConvertWarning:
UnsupportedElementWarning(format, element)PartialElementWarning(format, element, detail)FallbackUsedWarning(format, from_, to)ParseSkippedWarning(format, reason)- and a base
ConvertWarningfor legacy/unknown forms.
ConvertMetrics
parse_durationcodegen_durationcompile_durationtotal_durationinput_size_bytesoutput_size_bytespage_count
Duration fields are reported in seconds.
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
infer_format()reads the file suffix and accepts only.docx,.pptx, or.xlsx.convert_path()validates the file extension before conversion.convert_bytes()requires an explicit inputformat.
Exceptions
Re-exported exception hierarchy:
Office2PdfErrorUnsupportedFormatErrorOffice2PdfIoErrorOffice2PdfParseErrorOffice2PdfRenderErrorUnsupportedEncryptionErrorUnsupportedOptionError
API scope
Version 0.4.1 exposes the upstream office2pdf 0.9.1 conversion API: file/bytes conversion, conversion options, structured warnings, metrics, and typed errors.
The upstream pdf-ops APIs (page_count, merge, split), internal IR/parser/render modules, TypeScript helpers, and WASM APIs are intentionally out of scope for this Python release.
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 wheels for Linux (x86_64 and aarch64, manylinux_2_17 and musllinux_1_2), macOS (x86_64 and arm64), and Windows (x86_64) plus an sdist, then publishes with PyPI Trusted Publishing using GitHub OIDC (id-token: write). No PyPI API token is required. A manual dispatch builds and uploads the artifacts without publishing.
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.4.1
git push origin v0.4.1
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.9.1" from crates.io. The upstream project is Apache-2.0 licensed and hosted at https://github.com/developer0hye/office2pdf.
Metadata
Release files for office2pdf-python 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| office2pdf_python-0.4.1.tar.gz | 53.0 kB | With provenance | Details for office2pdf_python-0.4.1.tar.gz |
Built distributions (wheels)
Total release size: 221.1 MB
Release files / office2pdf_python-0.4.1.tar.gz
| Download URL | office2pdf_python-0.4.1.tar.gz |
|---|---|
| Size | 53.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cee8244e173a9a1cf8d2c03e61f49b389015a6bfc97f217022eef84da559b51a
|
|
BLAKE2b-256 checksum How to use checksums |
c7d22cbdbb4ba1f41d9b717068959c2de5aa69ed2b92b93d82cfcded1516e28d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-win_amd64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 29.5 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
293d9ad29b8dc7b9b17b04e3b58193cac6d54058c10ee9f551552dd32c86cf9f
|
|
BLAKE2b-256 checksum How to use checksums |
7da7153c31c8e9474c02741f3be6611b31222a2f4f30ddd16141dade143e338c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 34.0 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
92549aad77643287735a7b94ad6aa7cefe14018d1c0d9ac3f439635d720d6abc
|
|
BLAKE2b-256 checksum How to use checksums |
f8375f7781b7cebd0b3fed212dbc6cfbdbaed4b7f8a47474f804fcc99b831a1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 32.7 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
74377c936de3bb66196a6122353e967380afcb4d7dea1567a408f6135a2ae088
|
|
BLAKE2b-256 checksum How to use checksums |
b70b3ccfa7f7aff304061d7d14f19a122cd2778b190ab78f719e9ef2ed601ee8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 31.5 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1a8451c394d32339f53d2dc16502e07472c0b523ef7972886604aeb209f77091
|
|
BLAKE2b-256 checksum How to use checksums |
4f29de39f877319bbf91c0e096d6036ae16038d92962ec3b4cd89e57c53d06f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 33.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
119d7b244e4f7b8670a793fdb30d4cea119f701435a0b742506154bd95192cce
|
|
BLAKE2b-256 checksum How to use checksums |
12f206ebb6666cc296a1c71178e359a1a18b74612b943bfb69770731017f2986
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 30.2 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3d8be5a21ab3f2f0877bd0caaa27d0896eb8b1b8ce9c393d00ce209d18cffb98
|
|
BLAKE2b-256 checksum How to use checksums |
8e02ba9fa2c239bb915ee6fe119805f964f96b842a96712051f3730921dac334
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / office2pdf_python-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | office2pdf_python-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 30.1 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ccd6365a43c46ba94eb5e9d1595cd9e37014f72cd760381d8c93146000f9c7ca
|
|
BLAKE2b-256 checksum How to use checksums |
192440f0eb3116423a1b87fe6244d2b9e7f90c18900999ea64f09ae8cacfc1e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logSecurity for office2pdf-python 0.4.1
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.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for office2pdf_python-0.4.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logA 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.