Skip to main content

docx-rs

Fast DOCX-to-PDF conversion with a Rust layout engine whose output matches LibreOffice's, without running LibreOffice.

from docx_rs import convert, convert_bytes

convert("document.docx", "document.pdf")
pdf_bytes = convert_bytes(open("document.docx", "rb").read())

Conversions release the GIL, so threads convert in parallel.

Supported documents

The renderer only produces a PDF when it supports everything in the document. A document using unsupported features raises docx_rs.UnsupportedDocument, whose findings list each unsupported construct; it never returns an approximate PDF. Support currently covers typical generated legal documents: styles, numbering, tables, sections, headers and footers, fields such as cached tables of contents, text boxes and images. Use docx_rs.inspect(path) to see the eligibility report without converting.

Fonts

The package bundles open fonts and substitutes them for common Microsoft fonts: TeX Gyre Termes for Times New Roman, Bonum for Bookman Old Style, Carlito for Calibri/Aptos/Aptos Display, Caladea for Cambria, Liberation Sans and Mono for Arial and Courier New, OpenSymbol for Symbol and DejaVu Sans for Segoe UI Symbol, and explicit Linux Libertine G fallback for qualified uncovered scalars. Version 3 (debian-bookworm-open-v3) adds TeX Gyre Pagella for Palatino Linotype, EB Garamond for Garamond and Gelasio for Georgia. Version 4 (debian-bookworm-open-v4, the bundled default) adds TeX Gyre Schola for Century Schoolbook and Century. All mappings are explicitly chosen; the v2 mappings are independently qualified against LibreOffice, while the v3 and v4 additions are visual substitutes checked on representative documents (EB Garamond is not metric-compatible with Garamond, so pagination differs from Word). Each font keeps its own licence; see docx_rs/fonts/licenses/. A custom font profile can be passed as font_profile= (a profile JSON path or docx_rs.FontProfile.load(path)).

Two bundled presets are verified against LibreOffice using the same font files. docx_rs.bundled_profiles() lists their names and descriptions. default keeps LibreOffice-matching open substitutes. tnr-spacing uses the same substitutes, with Times New Roman and Times mapped to Termes TNR Spacing for Times New Roman line spacing and pagination, and Palatino Linotype, Bookman Old Style, Cambria, Georgia, Garamond, Century Schoolbook and Century mapped to derived spacing faces that carry the replaced font's line height:

import docx_rs

pdf = docx_rs.convert_bytes(data, font_profile=docx_rs.bundled_profile("tnr-spacing"))

Profiles are cached per name and shared safely across threads. Termes TNR Spacing is derived from TeX Gyre Termes under the GUST Font License: only vertical metrics are changed, and the faces are renamed; glyphs and widths remain unchanged. tools/derive_fonts.py reproduces the faces, whose SHA-256 hashes are pinned in fixtures/fonts/debian-bookworm-open-v2-tnr-spacing.json. It approximates Times New Roman pagination; slight glyph-width differences can still change line breaks. make bundled-fonts produces both relative-path profiles and their fonts; fontTools is a build-time dependency in the fonts uv group, not a wheel dependency.

Metadata

Release files for docx-rs-4jy72q 0.3.7

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

Built distributions (wheels)

Table of built distributions (wheels) for docx-rs-4jy72q 0.3.7
File Interpreter ABI Platform Actions
docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
docx_rs_4jy72q-0.3.7-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 Details for docx_rs_4jy72q-0.3.7-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 47.7 MB

Release files / docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 15.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fef6f8c44a73e1044b9f5ca37af25f717f462935fe4c0f110f6df25bdeba841a
BLAKE2b-256 checksum
How to use checksums
a998774e70537571055beeecc205d6d55882e8c3931094682742a24fcce95066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL docx_rs_4jy72q-0.3.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 14.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
14bf8fe649a5b54a8020c4cde13f5292b7e63d016d762ca02dc3fb4aafbdd0f6
BLAKE2b-256 checksum
How to use checksums
7aaaa62dddb51ac68e0126e3fca9a055083eb161e3240d3635e254360d776065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / docx_rs_4jy72q-0.3.7-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL docx_rs_4jy72q-0.3.7-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 17.8 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
12cd6618c6aa3cbf480bc07c9a15aa99bfd85667d4da3c4a1ed6f0d5fca1ef3a
BLAKE2b-256 checksum
How to use checksums
ff20b3777ee19987ef842eb8ca1e1dcea2090ac5d9a020759570ff0bcd3b2713
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for docx-rs-4jy72q 0.3.7

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