Anvil 0.3.0
See the version list below for details.
dotnet add package Anvil --version 0.3.0
NuGet\Install-Package Anvil -Version 0.3.0
<PackageReference Include="Anvil" Version="0.3.0" />
<PackageVersion Include="Anvil" Version="0.3.0" />
<PackageReference Include="Anvil" />
paket add Anvil --version 0.3.0
#r "nuget: Anvil, 0.3.0"
#addin nuget:?package=Anvil&version=0.3.0
#tool nuget:?package=Anvil&version=0.3.0
dotnet-anvil
Anvil API library for .NET. Anvil is a suite of tools for managing document-based workflows:
- Anvil Workflows converts your PDF forms into simple, intuitive websites that fill the PDFs and gather signatures for you.
- Anvil PDF Filling API allows you to fill any PDF with JSON data.
Installing
Using the dotnet
CLI:
$ dotnet add package Anvil --version 0.1.0-alpha2
Add as a package reference:
<ItemGroup>
<PackageReference Include="Anvil" Version="0.1.0-alpha2" />
</ItemGroup>
Usage
Create a client instance
using Anvil.Client;
var apiKey = "API-KEY-FROM-SETTINGS";
// For GraphQL-related queries
var client = new GraphQLClient(apiKey);
// If you are looking to use the PDF fill or PDF generate endpoints
// use the REST Client.
var restClient = new RestClient(apiKey);
Example usage
Also see the example in the examples/
directory.
using Anvil.Client;
using Anvil.Payloads.Request.Types;
using Anvil.Payloads.Response;
class Program
{
const string apiKey = "MY-API-KEY";
static async Task<bool> GeneratePdfExampleData()
{
var restClient = new RestClient(apiKey);
var payload = new Anvil.Payloads.Request.GeneratePdf
{
Title = "My Document Title",
Type = "markdown",
Data = new List<IGeneratePdfListable>
{
new GeneratePdfItem
{
Label = "new thing1",
Content = "Content1",
FontSize = "20",
TextColor = "#CC0000"
},
new GeneratePdfItem
{
Label = "new thing2",
Content = "Content2"
},
}
};
return await restClient.GeneratePdf(payload, "/path/for/file/what.pdf");
}
}
API
- RestClient.FillPdf
- RestClient.GeneratePdf
- RestClient.DownloadDocuments
- GraphQLClient.CreateEtchPacket
- GraphQLClient.GetEtchPacket
- GraphQLClient.GetEtchSignUrl
- GraphQLClient.DownloadDocuments
- GraphQLClient.SendQuery
RestClient.FillPdf
Fills a PDF template with your JSON data.
First, you will need to have uploaded a PDF to Anvil. You can find the PDF template's id on the API Info
tab of your PDF template's page:
<img width="725" alt="pdf-template-id" src="https://user-images.githubusercontent.com/69169/73693549-4a598280-468b-11ea-81a3-5df4472de8a4.png">
An example:
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"
} },
}
};
// This will return a `Stream`
await restClient.FillPdf("your-template-eid", payload);
// This will write directly to the path you specify
await restClient.FillPdf("your-template-eid", payload, "/tmp/file.pdf");
RestClient.GeneratePdf
Dynamically generate a new PDF from your HTML and CSS or markdown.
using Anvil.Client;
using Anvil.Payloads.Request.Types;
using Anvil.Payloads.Response;
class Program
{
const string apiKey = "MY-API-KEY";
static async Task<bool> GeneratePdfExampleData()
{
var restClient = new RestClient(apiKey);
var payload = new Anvil.Payloads.Request.GeneratePdf
{
Title = "My Document Title",
Type = "markdown",
Data = new List<IGeneratePdfListable>
{
new GeneratePdfItem
{
Label = "new thing1",
Content = "Content1",
FontSize = "20",
TextColor = "#CC0000"
},
new GeneratePdfItem
{
Label = "new thing2",
Content = "Content2"
},
}
};
return await restClient.GeneratePdf(payload, "/path/for/file/what.pdf");
}
}
RestClient.DownloadDocuments
Returns a Stream
of the document group specified by the documentGroupEid in Zip file format.
var restClient = new RestClient(apiKey);
return await restClient.DownloadDocuments("document-group-eid-here");
GraphQLClient.CreateEtchPacket
Creates an Etch Packet and optionally sends it to the first signer.
var client = new GraphQLClient(apiKey);
// This is from your "Document Templates" area in your Anvil account.
var templateId = "template-id-from-anvil";
// Add one or more files to a List for the upcoming payload.
// The "files" here are existing Casts in your Anvil account.
var files = new List<IEtchPacketAttachable>
{
new EtchCastRef
{
// Remember this `Id`. You will assign it to the signer below.
Id = "existingCastReference",
CastEid = templateId,
}
};
// Create your signer and also assign it to a signature field
// from the above template (the `Fields` property).
var signer = new EtchSigner
{
Id = "custom-signer-id",
Name = "Morgan Johnson",
Email = "morgan@example.com",
Fields = new[]
{
new SignerField
{
FieldId = "sign1",
FileId = "existingCastReference",
}
}
};
var signers = new List<EtchSigner> { signer };
// Put it all together.
var payload = new Anvil.Payloads.Request.CreateEtchPacket
{
Name = "Etch packet name",
IsDraft = false,
IsTest = true,
SignatureEmailBody = "Please sign this!",
SignatureEmailSubject = "Your signature is required",
Signers = signers.ToArray(),
Files = files.ToArray(),
// If you'd like all your PDFs merged into one when signing, and in the resulting zip package.
// Defaults to `false`.
// MergePdfs = true,
};
var response = await client.CreateEtchPacket(payload);
GraphQLClient.GetEtchPacket
Gets the details of an Etch Packet.
var client = new GraphQLClient(apiKey);
return await client.GetEtchPacket("etch-packet-eid-here");
GraphQLClient.GetEtchSignUrl
Generates an Etch sign URL for an Etch Packet signer. The Etch Packet and its signers must have already been created.
var client = new GraphQLClient(apiKey);
var signerEid = "some-id-here-from-etch-packet";
var clientUserId = "your-systems-signer-id";
var data = await client.GenerateEtchSignUrl(signerEid, clientUserId);
// The URL for signing is here
var url = data.GenerateEtchSignUrl;
GraphQLClient.SendQuery
A fallback function for queries and mutations without a specialized function in this client.
See the GraphQL reference for a listing on all possible queries.
var client = new GraphQLClient(apiKey);
var query = @"
query currentUser { currentUser { id } }
";
// `response` will be a `JObject` type and you can get different
// object fields by using the indexer operator (`[]`). Note that
// the field names are in the same case as in the query (camelCase)
// and won't follow the typical C# PascalCase as in the defined
// types in this library.
var response = await client.SendQuery(query, null);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- GraphQL.Client (>= 4.0.2)
- GraphQL.Client.Serializer.Newtonsoft (>= 4.0.2)
- GraphQL.Client.Serializer.SystemTextJson (>= 4.0.2)
-
.NETStandard 2.0
- GraphQL.Client (>= 4.0.2)
- GraphQL.Client.Serializer.Newtonsoft (>= 4.0.2)
- GraphQL.Client.Serializer.SystemTextJson (>= 4.0.2)
-
net5.0
- GraphQL.Client (>= 4.0.2)
- GraphQL.Client.Serializer.Newtonsoft (>= 4.0.2)
- GraphQL.Client.Serializer.SystemTextJson (>= 4.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.0 | 11,499 | 9/12/2022 |
0.4.0 | 438 | 9/7/2022 |
0.3.0 | 476 | 5/23/2022 |
0.2.0 | 480 | 3/4/2022 |
0.1.0-alpha3 | 182 | 1/25/2022 |
0.1.0-alpha2 | 192 | 1/20/2022 |
0.1.0-alpha1 | 197 | 1/20/2022 |
0.1.0-alpha | 203 | 1/20/2022 |