MiniPdf README

项目的 README,来自 github.com/mini-software/MiniPdf。合并为一个 markdown 文件:README.md。

Office-to-PDF conversion for .NET.

NuGet GitHub stars DOI License

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Italiano | Français

Online Demo · Releases · Report an issue

Contributions are welcome. See Contributing.

Convert XLSX, DOCX, and PPTX files with the .NET library, command-line tool, or standalone Native AOT builds. Microsoft Office, LibreOffice, Adobe Acrobat, and COM automation are not required at runtime.

.NET overview

Implementation Inputs Interfaces Maturity Documentation Visual results
.NET XLSX, DOCX, PPTX Library, CLI, Native AOT binaries Stable .NET guide XLSX
DOCX
PPTX

Quick start

Install the library

dotnet add package MiniPdf
using MiniSoftware;

MiniPdf.ConvertToPdf("workbook.xlsx", "workbook.pdf");
MiniPdf.ConvertToPdf("report.docx", "report.pdf");
MiniPdf.ConvertToPdf("slides.pptx", "slides.pdf");

byte[] pdfBytes = MiniPdf.ConvertToPdf("report.docx");

Use the command line

dotnet tool install --global MiniPdf.Cli
minipdf report.docx -o report.pdf
minipdf workbook.xlsx -o workbook.pdf --compress
minipdf slides.pptx -o slides.pdf
minipdf --help

Standalone builds run without an installed .NET runtime. Download a Native AOT binary from Releases.

Usage examples

Convert streams

using System.IO;
using MiniSoftware;

using var input = File.OpenRead("report.docx");
using var output = File.Create("stream-output.pdf");
MiniPdf.ConvertToPdf(input, output);

Dispose the input and output streams in the calling code. Use the overload returning byte[] when an in-memory result is needed.

Select Excel sheets and control layout

using MiniSoftware;

MiniPdf.ConvertToPdf("workbook.xlsx", "summary.pdf", new MiniPdfConversionOptions
{
    Sheets = new[] { "Summary" },
    Landscape = true,
    FitToPage = true,
    Compress = true,
});

Sheet names, 1-based SheetIndexes, orientation, print scale, and fit-to-page options apply to XLSX input. See the conversion options for the complete list.

Set Word page size and margins

using MiniSoftware;

MiniPdf.ConvertToPdf("report.docx", "a4-report.pdf", new MiniPdfConversionOptions
{
    PageSize = MiniPdfPageSize.A4,
    Margins = new MiniPdfMargins(left: 36, top: 48, right: 36, bottom: 48),
});

PageSize and Margins apply to DOCX input. Dimensions use PDF points: 72 points equal one inch. They do not override XLSX worksheet or PPTX slide sizes.

Reduce memory for large, simple Excel tables

using System.IO;
using MiniSoftware;

using var input = File.OpenRead("workbook.xlsx");
using var output = File.Create("low-memory.pdf");
MiniPdf.ConvertToPdf(input, output, new MiniPdfConversionOptions
{
    LowMemory = true,
    Compress = true,
});

Low-memory XLSX conversion requires writable temporary storage. Features such as formulas, merged cells, and drawings are unsupported and return an error; there is no automatic fallback. Read the supported features and limitations before enabling it. Returning byte[] still retains the complete PDF in memory.

Provide fonts for headless hosts

using System.IO;
using MiniSoftware;

MiniPdf.RegisterFont("Arial", File.ReadAllBytes(Path.Combine("Fonts", "arial.ttf")));
MiniPdf.ConvertToPdf("report.docx", "font-report.pdf");

Supply licensed .ttf or .ttc files that contain the required glyphs. Register fonts once at application startup: registrations are process-wide. MiniPdf does not distribute these font files.

See the .NET library guide and CLI reference for more examples and options.

Why MiniPdf

MiniPdf targets practical document conversion, not complete Microsoft Office layout compatibility. Complex templates may render differently; use the online demo or benchmark reports to evaluate representative files.

Contributing

Submit changes through pull requests. For bug reports, include a small input file and the steps needed to reproduce the problem.

Project resources

Resource Description
Online demo Try conversion in a browser
.NET documentation Stable library and CLI usage
CLI reference Commands, fonts, compression, and Excel preview options
.NET XLSX benchmark Visual comparison results for spreadsheets
.NET DOCX benchmark Visual comparison results for documents
GitHub releases Packages and standalone binaries
Issues Bugs, compatibility reports, and feature requests

License

Apache License 2.0. Commercial use is welcome

MiniPdf (mini-software/MiniPdf)

正在搜索数据库…

这是什么?MiniPdf 是一套轻量、快速的本地库和命令行工具,可以把 Office 文档(XLSX、DOCX、PPTX)转换成 PDF,提供 .NET (C#)、Rust、Java、Python、Node.js 和 Go 等多种语言实现。
它是库、命令行工具,还是两者都有?两者都有。每种实现都以对应生态的库形式发布,大多数还附带命令行工具;.NET 版本另外还提供独立的 Native AOT 可执行文件。
怎么转换我的第一个文档?安装你所用语言对应的包,然后调用一个函数即可——Node.js:先执行 'npm install minipdf',再调用 minipdf.convertToPdf('report.docx','report.pdf');Go:执行 'go get github.com/mini-software/MiniPdf/minipdf-go@latest'。
使用它需要安装 Microsoft Office 吗?不需要任何 Office 组件——MiniPdf 直接转换文档,运行时不依赖 Microsoft Office、LibreOffice、Adobe Acrobat,也不使用 COM 自动化。
每种实现实际能转换哪些 Office 格式?输入格式支持各不相同:.NET 支持 XLSX、DOCX 和 PPTX;Rust 和 Java 支持 XLSX 和 DOCX;Python 包目前只能转换 DOCX——选择实现前请先确认你要的格式是否被支持。
可以在商业软件中使用吗?可以——它采用 Apache License 2.0,明确欢迎商业使用。
哪些语言的移植版本是稳定的,哪些还处于实验阶段?.NET、Rust、Python 和 Node.js 的实现标记为稳定,Java 和 Go 则是实验性的——Go 移植版目前只发布了 XLSX 的可视化验证结果。
不安装任何东西可以试用吗?可以,项目提供了在线演示,直接在浏览器里就能测试转换效果。
如何检查 PDF 输出的还原度?仓库提供了基准测试页面,展示 .NET 和 Rust 转换 XLSX 与 DOCX 的可视化对比结果,你可以在采用之前先查看渲染效果。
大小
1.9 GB
星标
512
时长
9个月
提交 · 90 天