As we grow, we're seeing many programming languages being used to interact with our API. One overarching goal at Anvil is to make working with PDFs and paperwork as easy as possible. From a developer perspective, that goal translates into a developer being able to fill PDFs, generate PDFs, and gather signatures from the API in minutes. If you've built out a Workflow, it should only take minutes to set up starting the Workflow and querying status via the API.
To that end, we're happy to release our .Net / C# API client. It handles authentication, has methods for common REST and GraphQL calls, and provides methods for making custom REST and GraphQL requests against the API. It works with any .NET language: C#, F#, or Visual Basic.
Usage
If you don't have one already, sign up for an Anvil account to start experimenting with the API. Take a look at the getting started article to grab your API keys.
The Anvil API client is available on NuGet. Here are a few resources to get you started:
- Example.cs in the repo - A full, runnable example
- API client docs - All methods and their usage
- GraphQL API reference - Documentation for all GraphQL queries and mutations
Example: filling a PDF
Here's a quick snippet you can use to fill a template PDF with C#. Head over the github repo for full docs and examples.
using System.IO;
using Anvil.Client;
using Anvil.Payloads.Request.Types;
using Anvil.Payloads.Response;
class Program
{
const string apiKey = "MY-API-KEY";
static async Task<Stream> FillPdfExampleData()
{
var restClient = new RestClient(apiKey);
// Use Payload.Request objects to create your API call.
var payload = new Anvil.Payloads.Request.FillPdf
{
Title = "My PDF Title",
TextColor = "#CC0000",
Data = new Dictionary<string, object>
{
{ "simpleTextField", "string data" },
// Some fields are JSON objects, use an object initializer for those.
// In your PDF template's API info page, you can see if your field has
// additional data.
{ "phone", new {
Num = "5551231234",
Region = "US"
} },
}
};
// Return a `Stream`
return await restClient.FillPdf("W3rYELxNk6A4FQ68yrgP", payload);
// Or write to a file
// await restClient.FillPdf("W3rYELxNk6A4FQ68yrgP", payload, '/tmp/file.pdf');
}
}
Have questions?
If you have any feedback or just want to share something cool you're developing with PDFs, let us know at developers@useanvil.com. We’d love to hear from you!