minipdf-cli 0.2.0

Experimental Rust CLI for MiniPdf Office-to-PDF conversion.
minipdf-cli-0.2.0 is not a library.

MiniPdf for Rust

crates.io docs.rs License

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 and DOCX files. Use the .NET implementation for PPTX, content extraction, PDF merge, or broader production compatibility.

Requirements

  • Rust 1.82 or later
  • No Microsoft Office, LibreOffice, Adobe Acrobat, or .NET runtime at runtime

Library

Add the crate:

cargo add minipdf

Convert a file to a PDF on disk:

fn main() -> minipdf::Result<()> {
    minipdf::convert_to_pdf("report.docx", "report.pdf")?;
    Ok(())
}

Return PDF bytes instead:

let pdf = minipdf::convert_to_pdf_bytes("data.xlsx")?;

For a host with limited system fonts, register font bytes before conversion:

let font = std::fs::read("fonts/NotoSansSC-Regular.ttf")?;
minipdf::register_font("NotoSansSC", font);
minipdf::convert_to_pdf("report.docx", "report.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:

cargo install minipdf-cli

Convert with an automatically selected output name:

minipdf report.docx

Specify an output path or font directory:

minipdf data.xlsx -o data.pdf

minipdf report.docx --fonts ./fonts

minipdf convert report.docx -o report.pdf

Current Scope

Capability Rust status
XLSX to PDF Supported; rendering coverage is expanding
DOCX to PDF Supported; rendering coverage is expanding
PPTX to PDF Not supported
PDF merge Not supported
Markdown / JSON extraction Not supported
PDF output PDF 1.4
Fonts Built-in Helvetica and registered/system fallback fonts
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, and Unicode fallback fonts. Complex Office 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 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>.

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.

License

Apache License 2.0.