项目的 README,来自 github.com/mini-software/MiniPdf。合并为一个 markdown 文件:README.md。
Office-to-PDF conversion for .NET.
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.
| Implementation | Inputs | Interfaces | Maturity | Documentation | Visual results |
|---|---|---|---|---|---|
| .NET | XLSX, DOCX, PPTX | Library, CLI, Native AOT binaries | Stable | .NET guide | XLSX DOCX PPTX |
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");
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.
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.
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.
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.
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.
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.
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.
Submit changes through pull requests. For bug reports, include a small input file and the steps needed to reproduce the problem.
| 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 |
Apache License 2.0. Commercial use is welcome