Open source · MIT · C# and .NET 8, 9, 10 and 11

HTML to PDF in under a millisecond.

PdfPecker turns HTML and Markdown into PDFs, and PDFs into images, from plain .NET. No browser to start, no native binaries to ship, no third-party packages. Just one small DLL.

dotnet add package PdfPecker

From Python: pip install pdfpecker, with an MCP server for AI agents. From Rust: cargo add pdfpecker.

0.92 msfor a one-page invoice
1,132documents a second on 4 cores
92 MBpeak memory under load
0dependencies beyond .NET

Your first PDF in two lines

Every method is static and thread-safe, so you can convert many documents at once. Write the HTML the way you already do, with modern CSS, and get a PDF back as bytes, a stream or a file. The C# guide walks through invoices, headers and footers and ASP.NET Core.

  • Runs wherever .NET 8 or later runs: Windows, Linux, macOS, x64 and ARM64, containers and serverless
  • Pure managed code: a 6.3 MB DLL instead of a 600 MB browser
  • Never touches the network or your files unless you allow it
  • Rather write C#? PdfPecker.Fluent builds PDFs in code, in the style of QuestPDF
  • Test your PDFs: PdfPecker.Testing compares them with stored snapshots and marks changed pixels
Program.cs
using PdfPecker;

byte[] pdf = HtmlToPdf.Convert("<h1>Hello</h1><p>World</p>");
File.WriteAllBytes("hello.pdf", pdf);

// Or straight from ASP.NET Core
app.MapGet("/invoice", () =>
    Results.File(HtmlToPdf.Convert(html), "application/pdf", "invoice.pdf"));

Everything a business document needs

Built for invoices, payslips, reports, tickets and statements: the templates you control.

Modern CSS

Flexbox, grid and multi-column layout, var() and calc(), gradients, shadows, corner shapes, transforms, filters and masks, container queries, @scope, :has(), nesting, typed attr() and zoom, laid out as Chrome lays them out. All of it

Real fonts

TrueType, OpenType, WOFF and WOFF2, subset and embedded, with kerning, ligatures, variable fonts, colour emoji, tabular figures, full Unicode and automatic hyphenation in eleven languages.

Proper paging

Page margin boxes with running headers and running elements, page numbers in any counter style, even-page headers, its own margins for the first page, mirrored left and right pages, named pages, footnotes, tables of contents with page numbers, the page count and section page numbers anywhere in the content, repeated table headers, table rows that split across pages as in Chrome, orphans, widows and break control.

Right-to-left and complex scripts

Arabic and Hebrew with full shaping, set with dir or direction, including right-to-left tables, flex and grid. Devanagari and eight more Indic scripts, Khmer, Myanmar, Sinhala, Tibetan, Thai and Lao are shaped too. Chinese, Japanese and Korean break into lines by the kinsoku rules, with ruby and upright vertical text.

Images, SVG and barcodes

PNG, JPEG, GIF, WebP, BMP and TIFF, responsive srcset and picture, photos turned upright by their EXIF, and SVG drawn as crisp vectors with gradients, masks, patterns, embedded images and every SVG filter, inline or from files. QR codes, EPC payment and Swiss QR-bill codes, Data Matrix, Code 128 and EAN-13 are drawn for you, and scans and photos go straight into a PDF.

Digital signatures

PAdES signatures with your certificate or a key in an HSM or cloud key vault, visible signature boxes and trusted timestamps, or signed into the empty signature field of your template, and certification signatures that say what may change. Verify signed PDFs and keep them verifiable for years.

E-invoices

Factur-X, ZUGFeRD, XRechnung and Peppol XML built from your invoice data, with the totals and VAT calculated and checked against the EN 16931 standard of EU Directive 2014/55/EU, and a ready-made invoice layout in English, German or Danish. Invoice XML is embedded in a valid PDF/A-3 or read back out of the e-invoices you receive, and your PDF attached to Peppol and OIOUBL invoices.

Merge PDFs

Combine any PDFs, streamed one at a time, with links, bookmarks and form fields kept, and tagged files staying accessible. Or add them as they arrive.

Edit existing PDFs

Take out, reorder, rotate and split pages, stamp a PDF or put letterhead under it, make it smaller, add or remove a password, attach files, strip JavaScript and other active content, make it load fast on the web, and extract the text, images and document properties, on any PDF.

Fillable forms

Inputs, check boxes, radio buttons, selects and text areas become PDF form fields people can fill in, and the forms of existing PDFs can be filled and flattened from code.

Accessible PDFs

Tagged PDF, PDF/UA-1 and PDF/UA-2 built from your HTML, so screen readers follow headings, tables, lists and images.

PDF to image, HTML and Markdown

Its own renderer turns any PDF page into a PNG, JPEG or WebP image (or HTML straight into images), a whole PDF into one multi-page TIFF for fax and archives, or any PDF into one HTML page (with selectable, searchable text and working links, or as flowing headings, paragraphs and tables) or into Markdown. No Ghostscript or native code.

Links and bookmarks

Clickable links, jumps inside the document, bookmarks from your headings or CSS, page labels such as i to iv, and the page, zoom and panel the PDF opens with.

Safe by default

No JavaScript, no network, no file access unless allowed, page limits and cancellation for untrusted input.

Fast. Really fast.

Documents a second with one conversion per core on a 4-core cloud VM, on a 5-page document.

ConverterEngineTo deployInvoice, 1 pageReport, 30 pagesPeak memoryMemory
PdfPeckerown, managed6.3 MB DLL0.92 ms33 ms92 MB
HtmlRenderer.PdfSharpown, managed (CSS 2)5.0 MB of DLLs4.9 ms360 ms255 MB
wkhtmltopdfQt WebKit, nativeabout 90 MB282 ms600 ms165 MB
PuppeteerSharpChromiumabout 600 MB106 ms496 ms813 MB
PlaywrightChromiumbrowser + 135 MB131 ms517 ms1,027 MB

Medians after warm-up, Linux, .NET 10. Chromium runs JavaScript and is the reference for CSS; PdfPecker does not run scripts. How it was measured · Compare features

A tour of the API

// Markdown to PDF, styled like a GitHub README
byte[] pdf = MarkdownToPdf.Convert(File.ReadAllText("README.md"));

// Markdown to HTML: a body fragment, or a complete page with the stylesheet
string fragment = MarkdownToHtml.Convert("# Hello\n\n*World*");
string page = MarkdownToHtml.ConvertDocument(markdown);

Made for templates you control

PdfPecker is a document engine, not a web browser. That is what makes it fast and small.

Great for

  • Invoices, payslips and receipts
  • Reports and statements
  • Tickets, labels and letters
  • Docs and READMEs from Markdown

Not for

  • Pages that need JavaScript to render
  • Screenshots of live websites
  • Fetching images from the web on its own
  • Mongolian, Javanese and a few other scripts that need shaping (yet)

Peck your first PDF.

dotnet add package PdfPecker