DocxXlsx.PDFConverter 0.0.3

dotnet add package DocxXlsx.PDFConverter --version 0.0.3
                    
NuGet\Install-Package DocxXlsx.PDFConverter -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DocxXlsx.PDFConverter" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DocxXlsx.PDFConverter" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="DocxXlsx.PDFConverter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DocxXlsx.PDFConverter --version 0.0.3
                    
#r "nuget: DocxXlsx.PDFConverter, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DocxXlsx.PDFConverter@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DocxXlsx.PDFConverter&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=DocxXlsx.PDFConverter&version=0.0.3
                    
Install as a Cake Tool

PDFConverter

CI Build NuGet

A lightweight, free and open-source .NET library that converts DOCX and XLSX files to PDF using OpenXML SDK and PdfSharp/MigraDoc. No Microsoft Office installation required.

Why This Library?

I don't currently have the budget to pay for a licensed library to convert DOCX and XLSX files to PDF, even though there are many very good options on the market. So, I decided to build my own converter. It may or may not fit your needs. It's not the fastest option if you're looking for high performance, but it's good enough for me, especially considering that it's free. For simple files with simple objects, it should be enough.

This project was built with significant help from GitHub Copilot — from diagnosing tricky OpenXML quirks to fixing MigraDoc rendering issues, Copilot was an invaluable coding partner throughout the entire development process.

Features

  • DOCX → PDF — paragraphs, tables, images, headers/footers, styles, hyperlinks, VML textboxes, emoji
  • XLSX → PDF — cell formatting, merged cells, column widths, images (including floating images that overflow rows), connector shape rendering (signature lines)
  • Multiple input formats: file path, Stream, or byte[]
  • Output to file or byte[] for in-memory workflows
  • Embedded emoji font (Noto Emoji) for cross-platform rendering
  • No Office interop — runs on servers and containers

Installation

dotnet add package DocxXlsx.PDFConverter

Quick Start

using PDFConverter;

// DOCX to PDF — from file
Converters.DocxToPdf("report.docx", "report.pdf");

// DOCX to PDF — from stream
using var stream = File.OpenRead("report.docx");
Converters.DocxToPdf(stream, "report.pdf");

// DOCX to PDF — get bytes (no file I/O)
byte[] docxBytes = File.ReadAllBytes("report.docx");
byte[] pdfBytes = Converters.DocxToPdfBytes(docxBytes);

// XLSX to PDF
Converters.XlsxToPdf("data.xlsx", "data.pdf");

// XLSX to PDF — get bytes
byte[] xlsxBytes = File.ReadAllBytes("data.xlsx");
byte[] pdfBytes2 = Converters.XlsxToPdfBytes(xlsxBytes);

For more usage examples, see the Client Documentation.

Font Registration

To ensure fonts used in documents are available for PDF rendering:

// Register all fonts from a directory
OpenXmlHelpers.RegisterFontsFromDirectory("/path/to/fonts");

// Register specific font mappings
OpenXmlHelpers.RegisterFontMappings(new Dictionary<string, string>
{
    { "Calibri", "/path/to/Calibri.ttf" },
    { "Arial MT", "/path/to/ArialMT.ttf" }
});

Supported Features

Feature DOCX XLSX
Text formatting (bold, italic, underline, color, size)
Paragraph alignment and indentation
Tables with borders and shading
Conditional table formatting (header row, banded rows)
Inline and floating images
Connector shapes (signature lines)
Image cropping (srcRect)
Headers and footers
Hyperlinks
VML textboxes
Emoji
Tab stops
Merged cells
Landscape orientation

Known Limitations

  • Font substitution: If a document uses fonts not installed on the system, PdfSharp falls back to a default font which may cause minor layout differences.
  • EMF/WMF images: Vector image formats are not supported by PdfSharp and will be skipped.
  • Color emoji: Only monochrome emoji glyphs (Noto Emoji) are rendered; color emoji (COLR/CPAL) is not supported.
  • Image cropping: srcRect cropping uses System.Drawing.Bitmap which is Windows-only. On other platforms, the uncropped image is used as a graceful fallback.
  • Character width scaling: The w:w attribute is not supported by MigraDoc.
  • Complex layouts: Very complex Office features (advanced VML, SmartArt, charts) may not be reproduced exactly.

Building & Contributing

See the Developer Documentation for project structure, build instructions, and contribution guidelines.

dotnet build
dotnet test

License

MIT

The embedded Noto Emoji font is licensed under the SIL Open Font License 1.1.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3 121 2/15/2026
0.0.2 90 2/15/2026
0.0.1 103 2/14/2026