C#
Official .NET SDK for TemplateFox.
Installation
dotnet add package TemplateFox.SDKOr via Package Manager:
Install-Package TemplateFox.SDKGenerate a PDF
using TemplateFox.SDK.Api;
using TemplateFox.SDK.Client;
using TemplateFox.SDK.Model;
// Initialize the client
var config = new Configuration
{
ApiKey = new Dictionary<string, string>
{
{ "x-api-key", "your-api-key" }
}
};
var api = new PDFApi(config);
// Generate a PDF
var request = new CreatePdfRequest(
templateId: "YOUR_TEMPLATE_ID",
data: new Dictionary<string, object>
{
{ "name", "John Doe" },
{ "invoice_number", "INV-001" },
{ "total_amount", 150.00 }
}
);
try
{
var response = await api.CreatePdfAsync(request);
Console.WriteLine($"PDF URL: {response.Url}");
Console.WriteLine($"Credits remaining: {response.CreditsRemaining}");
}
catch (ApiException e)
{
Console.WriteLine($"Error: {e.Message}");
}Configuration
var config = new Configuration
{
ApiKey = new Dictionary<string, string>
{
{ "x-api-key", Environment.GetEnvironmentVariable("TEMPLATEFOX_API_KEY") }
}
};Full SDK Reference
For the complete API coverage including templates, account, S3 integration, and error handling, see the GitHub repository README .
Last updated on