Metadata-Version: 2.4
Name: docx-rs-4jy72q
Version: 0.3.1
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Summary: Fast DOCX-to-PDF rendering with a Rust layout engine that matches LibreOffice
License: Proprietary
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# docx-rs

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

```python
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. The bundled default is `debian-bookworm-open-v2`;
these mappings are explicitly chosen and independently qualified. 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:

```python
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.

