.NET
Get started with Pogodoc using .NET - from installation to your first document render
.NET Quickstart
Welcome! This guide will help you get started with Pogodoc using .NET. You'll learn how to install the SDK, authenticate, and generate your first document in minutes.
Prerequisites
Before you begin, make sure you have:
.NET 8.0+
Download from dotnet.microsoft.com
Pogodoc Account
Sign up at app.pogodoc.com
API Token
Generate from your dashboard
Quick Start Guide
Initialize the Client
Create a Pogodoc client with your API token. You can get your token from the API tokens page.
using Pogodoc;
var client = new PogodocApiClient("<YOUR_API_TOKEN>");Using Environment Variables
For better security, store your API token in an environment variable:
POGODOC_API_TOKEN=your_token_hereThen retrieve it in your code:
var token = Environment.GetEnvironmentVariable("POGODOC_API_TOKEN");
var client = new PogodocApiClient(token);Generate Your First Document
Now you're ready to generate a document! Here's a simple example using an EJS template:
using Pogodoc;
using Pogodoc.Documents;
var client = new PogodocApiClient(
Environment.GetEnvironmentVariable("POGODOC_API_TOKEN")
);
var template = @"
<!DOCTYPE html>
<html>
<head>
<title>Invoice</title>
<style>
body { font-family: Arial, sans-serif; }
h1 { color: #333; }
</style>
</head>
<body>
<h1>Invoice for <%= customerName %></h1>
<p>Amount: $<%= amount %></p>
<p>Date: <%= date %></p>
</body>
</html>
";
var data = new Dictionary<string, object>
{
{ "customerName", "John Doe" },
{ "amount", 1299.99 },
{ "date", DateTime.Now.ToString("MM/dd/yyyy") }
};
var response = await client.Documents.StartImmediateRenderAsync(
new StartImmediateRenderRequest
{
Template = template,
Data = data,
Type = StartImmediateRenderRequestType.Ejs,
Target = StartImmediateRenderRequestTarget.Pdf,
}
);
// Get the URL to your generated PDF
Console.WriteLine($"Document URL: {response.Output.Data.Url}");Success!
Your document is now generated and available at the returned URL. The URL is publicly accessible and can be shared or downloaded.
Next Steps
Now that you've generated your first document, explore the detailed SDK documentation: