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.
class GenerateMarkdownToPdf : RunnableBaseExample
{
private GeneratePdf GetPayload()
{
return new GeneratePdf()
{
Title = "Example Invoice",
Data = new List<IGeneratePdfListable>
{
new GeneratePdfItem()
{
Label = "Name",
Content = "Sally Jones",
},
new GeneratePdfItem()
{
Content = @"Lorem **ipsum** dolor sit _amet_, consectetur adipiscing elit, sed [do eiusmod](https://www.useanvil.com/docs) tempor incididunt ut labore et dolore magna aliqua. Ut placerat orci nulla pellentesque dignissim enim sit amet venenatis.
Mi eget mauris pharetra et ultrices neque ornare aenean.
* Sagittis eu volutpat odio facilisis.
* Erat nam at lectus urna.",
},
new GeneratePdfTable()
{
Table = new GeneratePdfTableContent()
{
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" },
}
},
},
}
};
}
public override async Task Run(string apiKey)
{
var payload = GetPayload();
var client = new RestClient(apiKey);
var wasWritten = await client.GeneratePdf(payload, "./output/generate-markdown-output.pdf");
}
}
The Anvil.Client package is MIT-licensed and maintained in the open on GitHub.
$ dotnet add package Anvil.ClientInstall the Anvil Document SDK plugin 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>