Introducing Anvil Document AI. Operate faster.Learn more.

Generate PDFs with C# & .NET

A simple API for generating PDFs within your app. Write C# & .NET to send HTML & CSS or Markdown to Anvil, get back a PDF.
Beyond Giant hero assetGiant hero assetDesktop hero assetMobile hero assetTablet hero asset

Perfectly formatted PDFs

Create dynamic and variable length PDFs with adjustments based on your content. Each page is perfectly scaled to a standard 8.5” x11” paper size.


C# & .NET to PDF

Use C# & .NET to lay out and generate your PDF for a 100% pixel perfect document.

class GenerateHtmlToPdf : RunnableBaseExample
{
    private GeneratePdf GetPayload()
    {
        return new GeneratePdf()
        {
            Title = "Example HTML to PDF",
            Type = "html",
            Data = new GeneratePdfHtml()
            {
                Html = @"
                    <h1 class='header-one'>What is Lorem Ipsum?</h1>
                    <p>
                    Lorem Ipsum is simply dummy text of the printing and typesetting
                    industry. Lorem Ipsum has been the industry's standard dummy text
                    ever since the <strong>1500s</strong>, when an unknown printer took
                    a galley of type and scrambled it to make a type specimen book.
                    </p>
                ",
                Css = @"
                    body { font-size: 14px; color: #171717; }
                    .header-one { text-decoration: underline; }
                ",
            },
        };
    }

    public override async Task Run(string apiKey)
    {
        var payload = GetPayload();
        var client = new RestClient(apiKey);
        var wasWritten = await client.GeneratePdf(payload, "./output/generate-html-output.pdf");
    }
}
  

Try it now


SOC2 logo
GDPR logo
HIPAA logo
EIDAS logo