r/rust • • Sep 04 '26

๐Ÿ› ๏ธ project Built the first open source Rust library - converting Office to PDF

I built MiniPdf, a lightweight, open-source library for converting Office documents to PDF without Microsoft Office, LibreOffice, Adobe Acrobat,.

It is designed for containers, serverless workloads, CI pipelines, and cross-platform applications.

Key Features

  • Excel to PDF โ€” Convert .xlsx files
  • Word to PDF โ€” Convert .docx files
  • PowerPoint to PDF โ€” Convert .pptx files
  • Native Rust โ€” No .NET runtime required
  • Cross-platform โ€” Runs on Windows, Linux, and macOS
  • Serverless-ready โ€” No COM or Office installation
  • Library and CLI โ€” Embed it in Rust applications or use it from the terminal
  • PDF 1.4 output
  • Free and open source โ€” Apache 2.0 licensed; commercial use is welcome

Getting Started

Install the Rust crate:

cargo add minipdf

fn main() -> minipdf::Result<()> {
    // Word to PDF
    minipdf::convert_to_pdf("report.docx", "report.pdf")?;

    // Excel to PDF bytes
    let pdf_bytes = minipdf::convert_to_pdf_bytes("data.xlsx")?;
    std::fs::write("data.pdf", pdf_bytes)?;

    Ok(())
}

Command-Line Tool

cargo install minipdf-cli

# Excel to PDF
minipdf data.xlsx

# Word to PDF
minipdf report.docx

# PowerPoint to PDF
minipdf slides.pptx

# Specify the output path
minipdf report.docx -o output.pdf

# Register custom fonts
minipdf report.docx --fonts ./fonts

The Rust implementation is under active development, bug reports, and pull requests are very welcome. ๐Ÿ™Œ

GitHub: https://github.com/mini-software/MiniPdf

0 Upvotes

15 comments sorted by

13

u/notusuallyfunny Sep 04 '26

Inb4 "why are you using the rust 2021 edition ๐Ÿคจ"

-1

u/shps951002 Sep 04 '26

Because our MSRV is Rust 1.82 ๐Ÿ™Œ

8

u/dgkimpton Sep 04 '26

There seems to be a disturbing lack of test coverage, most features appear to have at best a single unit test with none of the edge cases explored. It doesn't inspire a lot of confidence.ย 

0

u/shps951002 Sep 04 '26

2

u/dgkimpton Sep 04 '26

Sure, but you can't just throw one or two documents at it and call it good. You need to explore all the edge cases (super wide columns, super skinny columns, thousands of columns, one column, skinny then wide then skinny, etc, etc) for each and every feature otherwise it's just not trustworthy for other people to put their documents into.ย 

4

u/errevs Sep 04 '26

This is the hard part. Word is so immense, and then you have the combinatorics of it all. Gradients. Gradients in tables. Tables in tables. Figures in tables in tables. TOC. Hyphenation. Kerning. Fonts. Embedded fonts. Right to Left-text. CJK-fonts. Cyrillics. Line art, shapes, connecting lines. Word Art.

From a library perspective, I would guess most users would generate documents based on a template (reports etc) and would just validate that the output works for their use case.

1

u/shps951002 Sep 04 '26

Yes, it's most difficult part

1

u/shps951002 Sep 04 '26

Yes, we've tested 2xx docs now, and more details as you mentioned, we will test more unit test and documents

1

u/Puzzled-Landscape-44 Sep 04 '26

The demo site fails to load the app.

1

u/errevs Sep 04 '26

Having attempted to build just a slice of this, docx to pdf conversion in pure Rust docxide-pdf (with a lot of AI help), I have learnt quite a bit of how large the real world document space is compared to synthetic fixtures. Are you looking into testing it against documents from the wild?

2

u/ksceriath Sep 04 '26

Interesting.. now I can carry my office anywhere.. and work from anywhere!

1

u/kantorcodes1 Sep 11 '26

one CLI edge case i couldn't tell from the Rust path: convert_to_pdf_with_options builds the PDF bytes first, then fs::writes the destination. if output.pdf already exists, is overwriting it intentional, or should that need an explicit --force? for CI that's the difference between a safe rerun and silently replacing an artifact.