Developer quickstart
Generate PDFs in C# and .NET
Use HttpClient to authenticate, serialize a data payload, and save the PDF response stream.
Prerequisites
- A PDFDesignAPI account and API token.
- A template UUID with a schema and at least one data binding.
- Trusted server-side code where the token remains secret.
Generate and save the PDF
using System.Net.Http.Headers;
using System.Net.Http.Json;
using var request = new HttpRequestMessage(
HttpMethod.Post,
$"https://pdfdesignapi.com/api/v1/generate/single/{templateUuid}");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);
request.Content = JsonContent.Create(new {
data = new { customer = new { name = "Example BV" } }
});
using var response = await httpClient.SendAsync(
request,
HttpCompletionOption.ResponseHeadersRead,
cancellationToken);
response.EnsureSuccessStatusCode();
await using var output = File.Create("document.pdf");
await response.Content.CopyToAsync(output, cancellationToken);Production notes
- Reuse an injected HttpClient rather than constructing one per request in production.
- Pass cancellation tokens through the complete workflow.
- Inspect the error body before deciding whether a request is safe to retry.