.NET getting started

Generate PDF bytes
from .NET

Install one managed package and run the native Rust renderer inside your process.

.NET 8+ · NuGet · Linux, macOS, Windows

Install from NuGet

Add the package to any .NET 8 or newer project. NuGet selects the native asset for the current runtime identifier.

dotnet add package Ironpress

The package supports Linux x64 and ARM64 with glibc 2.28 or newer, macOS x64 and ARM64, and Windows x64.

Create an HTML PDF

using Ironpress;

using var converter = new HtmlConverter();
byte[] pdf = converter.ConvertHtml(
    "<h1>Hello from .NET</h1>"
);

File.WriteAllBytes("output.pdf", pdf);
Deterministic ownership

The managed converter uses a safe native handle. A using declaration releases it deterministically and the runtime retains a final safety net.

Render Markdown

The same configured converter accepts Markdown and returns an owned byte array:

byte[] pdf = converter.ConvertMarkdown(
    "# Release notes\n\nEverything shipped."
);

Reuse a configured converter

Configuration methods return the same converter, so related page and quality choices remain readable together.

using var converter = new HtmlConverter()
    .SetPageSize(PageSize.Letter)
    .SetMargins(PageMargins.FromPoints(36, 36, 48, 36))
    .SetCompression(true)
    .SetImageResolution(144)
    .SetSanitization(true)
    .SetHeader("Quarterly report")
    .SetFooter("Page {page} of {pages}");

byte[] first = converter.ConvertHtml(firstDocument);
byte[] second = converter.ConvertHtml(secondDocument);

Provide fonts as bytes

The managed API accepts custom TrueType fonts and optional CJK or emoji packs as bytes. It never downloads a font implicitly.

using var converter = new HtmlConverter()
    .AddFont("MyFont", File.ReadAllBytes("MyFont.ttf"))
    .AddFontPack(
        FontPackKind.CjkJapanese,
        File.ReadAllBytes("ironpress-font-cjk-jp.ttf")
    );

Handle failures and runtime limits

Renderer failures throw IronpressException. Its Kind keeps the stable parse, layout, render, font, security, or argument category.

  • HTML sanitization is enabled by default.
  • Converters must not be used or disposed concurrently.
  • Local paths, direct file output, async, streaming, and remote HTTP are absent.
  • The managed package verifies ABI generation 1 before allocating a converter.

Go further