Convert Markdown to PDF in C#

MarkdownToPdfConverter is Markdown to DOCX, then DOCX to PDF, in one call. Everything the Markdown converter guarantees carries over: nothing reaches the network or the disk.

using DocToolkit;

string markdown = "# Invoice 2026-114\n\nDue on receipt";
byte[] pdf = MarkdownToPdfConverter.Convert(markdown);
File.WriteAllBytes("output.pdf", pdf);

What it needs

  • No browser, headless or otherwise.
  • No Office install, and no LibreOffice.
  • No native files: managed code only.
  • No network at runtime, unless you ask for it.

Good to know

  • Synchronous: Convert takes the Markdown as a string and returns the PDF as a byte[].
  • An ordered list that starts below 1, such as 0. item, is refused by the PDF stage, though it converts to DOCX without trouble.
  • ConvertWithReport reports on the Markdown to DOCX half only; the PDF render reports nothing.
  • The fidelity limits of DOCX to PDF apply here too.

Install

dotnet add package Ank.DocToolkit

NuGetDocumentationGitHub