Tideway.MsgToPdf 1.1.0

dotnet add package Tideway.MsgToPdf --version 1.1.0
                    
NuGet\Install-Package Tideway.MsgToPdf -Version 1.1.0
                    
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="Tideway.MsgToPdf" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tideway.MsgToPdf" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Tideway.MsgToPdf" />
                    
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 Tideway.MsgToPdf --version 1.1.0
                    
#r "nuget: Tideway.MsgToPdf, 1.1.0"
                    
#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 Tideway.MsgToPdf@1.1.0
                    
#: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=Tideway.MsgToPdf&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Tideway.MsgToPdf&version=1.1.0
                    
Install as a Cake Tool

Tideway.MsgToPdf

Converts Outlook .msg email files to PDF. No Outlook/COM required; runs on Windows, macOS and Linux.

Pipeline: MsgReader extracts the message as HTML (an Outlook-print-style header block, the body — HTML, RTF or plain text — and inline images embedded as data URIs), then PuppeteerSharp renders it to PDF with headless Chromium.

Usage

using Tideway.MsgToPdf;

await using var converter = new MsgToPdfConverter();

// bytes → bytes
byte[] pdf = await converter.ConvertAsync(msgBytes);

// or file → file
await converter.ConvertFileAsync("mail.msg", "mail.pdf");

The converter keeps one Chromium instance alive across calls — reuse a single instance for batch conversions and dispose it when done.

Options

var converter = new MsgToPdfConverter(new MsgToPdfOptions
{
    IncludeMessageHeader = true,          // From/Sent/To/Cc/Subject/Attachments block (default true)
    NeutralizeOutlookPageBreaks = true,   // stop Outlook's WordSection CSS forcing a blank first page (default true)
    AppendPdfAttachments = false,         // merge the message's PDF attachments after the body (default false)
    OnWarning = w => log.Warn(w),         // non-fatal issues, e.g. an encrypted attachment skipped
    PaperFormat = PaperFormat.A4,         // default A4
    Landscape = false,
    Margins = new MarginOptions { Top = "15mm", Bottom = "15mm", Left = "12mm", Right = "12mm" },
    PageFooterTemplate = null,            // Chromium print footer HTML (pageNumber/totalPages spans)
    ChromiumExecutablePath = null,        // null → BrowserFetcher downloads Chromium on first use
    ChromiumArgs = new[] { "--no-sandbox" },
});

PDF attachments

With AppendPdfAttachments = true, the message's non-inline .pdf attachments are merged (in attachment order) after the rendered body via Tideway.PdfTools, producing one PDF — e.g. an email plus its report appendices. Password-protected or unparseable attachments are skipped and reported through OnWarning. The native libqpdf library is required only when this option is enabled (see the PdfTools README for per-platform setup).

Intermediate HTML

string html = MsgToPdfConverter.RenderHtml(msgStream);   // self-contained HTML document
byte[] pdf  = await converter.HtmlToPdfAsync(html);      // also usable for generic HTML → PDF

Chromium

By default the first conversion downloads a private Chromium build (~150 MB, cached in the user profile). In containers, install Chromium in the image instead and point the converter at it:

RUN apt-get update && apt-get install -y chromium && rm -rf /var/lib/apt/lists/*
new MsgToPdfOptions
{
    ChromiumExecutablePath = "/usr/bin/chromium",
    ChromiumArgs = new[] { "--no-sandbox" },   // needed when running as root
}

Notes

  • RTF-only bodies are converted with RtfPipe; Outlook's usual RTF-encapsulated HTML is handled by MsgReader itself.
  • External images (http(s) references) are fetched during rendering when reachable; unreachable ones render as broken-image icons.
  • cid: inline images are embedded as base64 data URIs, so the intermediate HTML is fully self-contained.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.1.0 236 8/13/2026
1.0.0 180 7/2/2026