MiniPdf for Rust
The experimental native Rust implementation of MiniPdf. It provides the
reusable minipdf crate and the minipdf-cli package, whose installed binary is
named minipdf.
Project portal · crates.io · API documentation · .NET implementation
The Rust implementation is under active development and is not yet feature-equivalent with MiniPdf for .NET. It currently converts XLSX, DOCX, and PPTX files. Use the .NET implementation for broader production compatibility.
Requirements
- Rust 1.82 or later
- No Microsoft Office, LibreOffice, Adobe Acrobat, or .NET runtime at runtime
Library
Add the crate:
Convert a file to a PDF on disk:
Return PDF bytes instead:
let pdf = convert_to_pdf_bytes?;
Override the output page size with a preset or custom dimensions:
let options = ConversionOptions ;
convert_to_pdf_with_options?;
let custom = ConversionOptions ;
convert_to_pdf_with_options?;
Custom dimensions use PDF points, where 72 points equal one inch. XLSX
conversion uses an explicit API override first, then the worksheet pageSetup
paper size and orientation. DOCX conversion uses the section page size and
margins unless the API overrides the page size. PPTX conversion uses the
presentation slide size unless the API overrides it. A document without
recognized page geometry uses its format default.
For a host with limited system fonts, register font bytes before conversion:
let font = read?;
register_font;
convert_to_pdf?;
The public API also supports in-memory Office package bytes through
convert_bytes_to_pdf and package inspection through detect_office_format.
Command Line
Install the CLI from crates.io:
Convert with an automatically selected output name:
Specify an output path or font directory:
Select A4 or Letter paper, or provide custom dimensions in PDF points:
--paper-size cannot be combined with --page-width and --page-height.
Custom width and height must be provided together.
Current Scope
| Capability | Rust status |
|---|---|
| XLSX to PDF | Supported; rendering coverage is expanding |
| DOCX to PDF | Supported; rendering coverage is expanding |
| PPTX to PDF | Supported; rendering coverage is expanding |
| PDF output | PDF 1.4 |
| Fonts | Built-in Helvetica and registered/system fallback fonts |
| Page size | Office page/slide geometry, A4/Letter presets, or custom point dimensions |
| Interfaces | Rust crate and native CLI |
The converter preserves sparse worksheet row positions, paginates wide sheets horizontally, and supports basic spreadsheet styling, drawing images, document text, explicit DOCX page breaks, basic DOCX tables, and Unicode fallback fonts. PPTX support includes themes and placeholders, basic shapes and connectors, text, raster and SVG images, tables, and SmartArt drawing fallbacks. Complex shape geometry, transforms, animations, and Office-specific layout can still differ from the source application.
Development
The Rust implementation is an independent Cargo workspace:
minipdf-rs/
|-- Cargo.toml
`-- crates/
|-- minipdf/ # Library API and conversion engine
`-- minipdf-cli/ # CLI binary named minipdf
Run the standard checks from this directory:
cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo run -p minipdf-cli -- path\to\input.docx
Visual Benchmarks
Run shared fixtures against Microsoft 365 and LibreOffice from the repository root:
.\scripts\Run-Rust-Benchmark.ps1 -Suite classic -Format xlsx
.\scripts\Run-Rust-Benchmark.ps1 -Suite classic -Format docx
.\scripts\Run-Rust-Benchmark.ps1 -Suite issue -Format xlsx
.\scripts\Run-Rust-Benchmark.ps1 -Suite issue -Format docx
.\scripts\Run-Rust-Benchmark-Matrix.ps1 -MaxComparePages 1
The benchmark reuses the repository fixtures, references, and PDF comparison
pipeline without executing the C# xUnit tests. Each run writes coverage data,
Markdown and JSON reports, side-by-side images, and heatmaps under
artifacts/rust-benchmark/<suite>/<format>.
Microsoft 365 is the primary reference used for text, visual, page-count, and overall scores. LibreOffice is generated on every run as an auxiliary reference and is included in the visual report without affecting those scores.
The matrix is generated at artifacts/rust-benchmark/benchmark_matrix.md and
links to the fixture coverage and comparison reports from each run.
Publishing
Both packages are published to crates.io. Repository releases tagged
rust-v<version> publish minipdf first and then minipdf-cli through GitHub
Actions.