Turn HTML or Markdown into branded, production-ready PDFs from your .NET application. The Anvil C# SDK provides an async-first API with strongly typed models for PDF generation.
using Anvil;
using Anvil.Payloads;
namespace AnvilExamples;
public static class GenerateMarkdown
{
public static async Task Run(AnvilClient anvil, string[] args)
{
var outputPath = args.Length > 0 ? args[0] : "generate-markdown-output.pdf";
var payload = new GeneratePdfPayload
{
Title = "Example Invoice",
// Markdown is the default type
Data = new List<MarkdownContent>
{
new() { Label = "Name", Content = "Sally Jones" },
new() { Content = "Lorem **ipsum** dolor sit _amet_, consectetur adipiscing elit." },
new()
{
Table = new MarkdownTable
{
FirstRowHeaders = true,
Rows = new List<List<string?>?>
{
new() { "Description", "Quantity", "Price" },
new() { "4x Large Widgets", "4", "$40.00" },
new() { "10x Medium Sized Widgets in dark blue", "10", "$100.00" },
new() { "10x Small Widgets in white", "6", "$60.00" },
},
},
},
},
};
await anvil.GeneratePdfToFileAsync(payload, outputPath);
Console.WriteLine($"Generated a PDF from Markdown and saved it to {outputPath}");
}
}
The Anvil package is MIT-licensed and maintained in the open on GitHub.
$ dotnet add package AnvilInstall the Anvil Document SDKplugin in Claude Code and Claude will scaffold the SDK into your codebase — discovery, planning, and production-ready code.
/plugin marketplace add anvilco/anvil-plugins
/plugin install anvil-document-sdk@anvil-pluginsNo API key setup needed. The plugin connects to your Anvil account with OAuth and logs you in automatically.
Use custom HTML and CSS to lay out a 100% pixel-perfect document. Typical response time under 250ms, with 99% of requests completing in under 3.3 seconds. Try the example below and see documentation when ready to generate your own.
<!-- Generate an invoice PDF. Full code: https://github.com/anvilco/html-pdf-invoice-template --> <div class="page-container"> Page <span class="page"></span> of <span class="pages"></span> </div> <div class="logo-container"> <img style="height: 18px" src="https://app.useanvil.com/img/email-logo-black.png" > </div> <table class="invoice-info-container"> <tr> <td rowspan="2" class="client-name"> Client Name </td> <td> Anvil Co </td> </tr> <tr> <td> 123 Main Street </td> </tr> <tr> <td> Invoice Date: <strong>May 24th, 2024</strong> </td> <td> San Francisco CA, 94103 </td> </tr> <tr> <td> Invoice No: <strong>12345</strong> </td> <td> hello@useanvil.com </td> </tr> </table> <table class="line-items-container"> <thead> <tr> <th class="heading-quantity">Qty</th> <th class="heading-description">Description</th> <th class="heading-price">Price</th> <th class="heading-subtotal">Subtotal</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>Blue large widgets</td> <td class="right">$15.00</td> <td class="bold">$30.00</td> </tr> <tr> <td>4</td> <td>Green medium widgets</td> <td class="right">$10.00</td> <td class="bold">$40.00</td> </tr> <tr> <td>5</td> <td>Red small widgets with logo</td> <td class="right">$7.00</td> <td class="bold">$35.00</td> </tr> </tbody> </table> <table class="line-items-container has-bottom-border"> <thead> <tr> <th>Payment Info</th> <th>Due By</th> <th>Total Due</th> </tr> </thead> <tbody> <tr> <td class="payment-info"> <div> Account No: <strong>123567744</strong> </div> <div> Routing No: <strong>120000547</strong> </div> </td> <td class="large">May 30th, 2024</td> <td class="large total">$105.00</td> </tr> </tbody> </table> <div class="footer"> <div class="footer-info"> <span>hello@useanvil.com</span> | <span>555 444 6666</span> | <span>useanvil.com</span> </div> </div>