<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TemplateMaster</title>
    <description>The latest articles on DEV Community by TemplateMaster (@templatemaster).</description>
    <link>https://dev.to/templatemaster</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3602366%2F27fd112c-a266-44e5-ab61-f1a6ac1fb48e.png</url>
      <title>DEV Community: TemplateMaster</title>
      <link>https://dev.to/templatemaster</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/templatemaster"/>
    <language>en</language>
    <item>
      <title>Generate Invoices as PDFs via API in C# (Step by Step)</title>
      <dc:creator>TemplateMaster</dc:creator>
      <pubDate>Wed, 04 Feb 2026 13:02:57 +0000</pubDate>
      <link>https://dev.to/templatemaster/generate-invoices-as-pdfs-via-api-in-c-step-by-step-1c5o</link>
      <guid>https://dev.to/templatemaster/generate-invoices-as-pdfs-via-api-in-c-step-by-step-1c5o</guid>
      <description>&lt;p&gt;Yet in many C# applications, generating a clean and reliable invoice PDF still feels harder than it should be.&lt;/p&gt;

&lt;p&gt;Between PDF libraries, HTML-to-PDF tools, layout bugs, and infrastructure issues, what looks like a simple feature often turns into a maintenance nightmare.&lt;/p&gt;

&lt;p&gt;In this article, I’ll show you how to generate invoice PDFs in C# using an API-first approach, with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML templates&lt;/li&gt;
&lt;li&gt;dynamic JSON data&lt;/li&gt;
&lt;li&gt;no PDF logic in your backend&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why invoice PDF generation is still painful in .NET&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’ve worked on invoice generation before, this probably sounds familiar:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Layout breaks when data grows&lt;/li&gt;
&lt;li&gt;PDF libraries tightly coupled to business logic&lt;/li&gt;
&lt;li&gt;Headless browsers crashing in production&lt;/li&gt;
&lt;li&gt;Every layout change requires a redeploy&lt;/li&gt;
&lt;li&gt;Only developers can edit templates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Invoices evolve constantly: branding, legal mentions, taxes, languages.&lt;br&gt;
Embedding all of that directly inside your backend does not scale.&lt;/p&gt;

&lt;p&gt;That’s why treating document generation as a separate service makes a huge difference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The API-first approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of generating PDFs inside your C# application, we’ll:&lt;br&gt;
(using a document generation API like &lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;TemplateMaster&lt;/a&gt;)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an HTML invoice template&lt;/li&gt;
&lt;li&gt;Store and version it in TemplateMaster&lt;/li&gt;
&lt;li&gt;Send invoice data as JSON&lt;/li&gt;
&lt;li&gt;Let the API generate the PDF&lt;/li&gt;
&lt;li&gt;Receive a ready-to-use file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your backend focuses on business logic.&lt;br&gt;
The document layer becomes external, reusable, and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 – Create an invoice HTML template&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s a simplified invoice template example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Invoice #{{invoiceNumber}}&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;
  &amp;lt;strong&amp;gt;Customer&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;
  {{customer.name}}&amp;lt;br /&amp;gt;
  {{customer.address}}
&amp;lt;/p&amp;gt;

&amp;lt;table width="100%" border="1" cellspacing="0" cellpadding="8"&amp;gt;
  &amp;lt;thead&amp;gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;th&amp;gt;Description&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;Unit price&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;Total&amp;lt;/th&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/thead&amp;gt;
  &amp;lt;tbody&amp;gt;
    {{#each items}}
    &amp;lt;tr&amp;gt;
      &amp;lt;td&amp;gt;{{description}}&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{quantity}}&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{price}} €&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{total}} €&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    {{/each}}
  &amp;lt;/tbody&amp;gt;
&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;
  &amp;lt;strong&amp;gt;Total amount:&amp;lt;/strong&amp;gt; {{totalAmount}} €
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This template:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is readable&lt;/li&gt;
&lt;li&gt;supports loops&lt;/li&gt;
&lt;li&gt;can be edited by non-developers&lt;/li&gt;
&lt;li&gt;doesn’t require any C# change when updated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2 – Upload the template to TemplateMaster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once uploaded to TemplateMaster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the template is versioned&lt;/li&gt;
&lt;li&gt;editable via a visual editor&lt;/li&gt;
&lt;li&gt;reusable across environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each template has a unique identifier, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;813a5147-a68c-4c37-b194-124100368efa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This identifier will be used by your backend when generating PDFs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 – Prepare invoice data in C#&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now let’s build the invoice payload in C#:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var invoiceData ={
    "templateCode": "813a5147-a68c-4c37-b194-124100368efa",
    "version": 0,
    "data": {
        "name": "John Doe",
        "address": "1234 Main St, Anytown, AN 12345",
        "items": [
            {
                "description": "Product 1",
                "quantity": 2,
                "price": 30.00
            },
            {
                "description": "Product 2",
                "quantity": 1,
                "price": 15.50
            }
        ],
        "total": 75.50,
        "date": "2023-07-30",
        "metadata": {
            "title": "Service Agreement",
            "author": "TemplateMaster",
            "subject": "Commercial agreement between TemplateMaster and ABC Company",
            "keywords": ["contract", "services", "TemplateMaster", "ABC Company"],
            "creator": "TemplateMaster API",
            "producer": "TemplateMaster PDF Engine",
            "createdAt": "2025-10-14T10:30:00Z",
            "modifiedAt": "2025-10-14T10:31:00Z"
        },
        "indexes":[
            { "DocumentType": "Facture" },
            { "InvoiceNumber":  "F2025-00123" },
            { "CreatedBy": "TemplateMaster" }
        ]
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This object matches the variables used in the HTML template.&lt;/p&gt;

&lt;p&gt;No formatting logic.&lt;br&gt;
No PDF concerns.&lt;br&gt;
Just data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 – Call the PDF generation API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we send the template ID and data to TemplateMaster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using var client = new HttpClient();

var request = new
{
    templateId = "invoice-default",
    data = invoiceData
};

var response = await client.PostAsJsonAsync(
    "https://api.templatemaster.io/pdf/generate",
    request
);

var pdfBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("invoice.pdf", pdfBytes);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s all it takes.&lt;/p&gt;

&lt;p&gt;No PDF engine.&lt;br&gt;
No headless browser.&lt;br&gt;
No rendering logic in your backend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 – Use the PDF anywhere&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once generated, the PDF can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;emailed to customers&lt;/li&gt;
&lt;li&gt;stored for accounting&lt;/li&gt;
&lt;li&gt;archived for compliance&lt;/li&gt;
&lt;li&gt;exposed via an API&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the invoice layout changes?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update the template&lt;/li&gt;
&lt;li&gt;No backend redeploy&lt;/li&gt;
&lt;li&gt;No code change&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why this approach scales better&lt;/strong&gt;&lt;br&gt;
Approach    Problems&lt;br&gt;
PDF libraries   Tight coupling, hard to evolve&lt;br&gt;
HTML-to-PDF in backend  Infra heavy, unstable&lt;br&gt;
API-based generation    Clean, scalable, maintainable&lt;/p&gt;

&lt;p&gt;This pattern works especially well when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;invoices evolve frequently&lt;/li&gt;
&lt;li&gt;multiple teams collaborate&lt;/li&gt;
&lt;li&gt;you run a SaaS or multi-tenant system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Final thoughts&lt;/p&gt;

&lt;p&gt;Invoice PDF generation shouldn’t slow your team down.&lt;/p&gt;

&lt;p&gt;By externalizing document generation behind an API, you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reduce complexity&lt;/li&gt;
&lt;li&gt;move faster&lt;/li&gt;
&lt;li&gt;keep your backend clean&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re building a serious C# application, this is a pattern worth adopting early.&lt;/p&gt;

&lt;h3&gt;
  
  
  Try it locally
&lt;/h3&gt;

&lt;p&gt;If you want to experiment with this approach, I’m using&lt;br&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;TemplateMaster&lt;/a&gt;&lt;/strong&gt; to manage templates and generate PDFs via API.&lt;/p&gt;

&lt;p&gt;You can try it without changing your C# setup or PDF stack.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>pdf</category>
      <category>dotnet</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Automate Shopify Order Emails &amp; PDF Invoices Using TemplateMaster API + Webhooks</title>
      <dc:creator>TemplateMaster</dc:creator>
      <pubDate>Tue, 09 Dec 2025 15:16:59 +0000</pubDate>
      <link>https://dev.to/templatemaster/automate-shopify-order-emails-pdf-invoices-using-templatemaster-api-webhooks-4ffb</link>
      <guid>https://dev.to/templatemaster/automate-shopify-order-emails-pdf-invoices-using-templatemaster-api-webhooks-4ffb</guid>
      <description>&lt;p&gt;When a new order is created in Shopify, many merchants want to automatically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate a PDF invoice&lt;br&gt;
Send a confirmation email&lt;br&gt;
Store or archive the document&lt;br&gt;
Trigger backend processes&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But doing this manually — or building your own PDF generation engine — is complex and time-consuming.&lt;/p&gt;

&lt;p&gt;In this article, I’ll show you how to integrate Shopify Webhooks with the TemplateMaster API to automatically send invoices and emails whenever a new order is created.&lt;/p&gt;

&lt;p&gt;This works with any backend language (C#, Node.js, Python, PHP…).&lt;/p&gt;

&lt;p&gt;🧩 What is TemplateMaster?&lt;/p&gt;

&lt;p&gt;TemplateMaster is a SaaS designed for developers and businesses who need:&lt;/p&gt;

&lt;p&gt;📝 HTML/CSS template editor&lt;br&gt;
📄 PDF generation via API&lt;br&gt;
✉️ Email sending API&lt;br&gt;
🔐 API key protection&lt;br&gt;
🧩 JSON-based dynamic rendering&lt;br&gt;
🗂️ Storage + versioning of templates&lt;/p&gt;

&lt;p&gt;It is perfect for invoices, receipts, order confirmations, shipping docs, etc.&lt;/p&gt;

&lt;p&gt;👉 Try it here: &lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;https://templatemaster.fr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📦 Shopify Webhook + TemplateMaster Workflow&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Customer places an order
⬇️&lt;/li&gt;
&lt;li&gt;Shopify triggers the orders/create webhook
⬇️&lt;/li&gt;
&lt;li&gt;Your server receives the webhook
⬇️&lt;/li&gt;
&lt;li&gt;Your server calls TemplateMaster API to:&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate a PDF invoice&lt;br&gt;
Send an email to the customer (with PDF attached)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;⬇️&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Shopify customer receives your customized invoice&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Configure the Shopify Webhook&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Shopify Admin:&lt;/p&gt;

&lt;p&gt;Settings → Notifications → Webhooks → Create Webhook&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Event: Order creation (orders/create)&lt;br&gt;
Format: JSON&lt;br&gt;
URL: Your API endpoint (e.g. &lt;a href="https://your-server.com/webhooks/shopify/order-created" rel="noopener noreferrer"&gt;https://your-server.com/webhooks/shopify/order-created&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Shopify will POST the full order JSON to your server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Example of Webhook Receiver (Node.js)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This endpoint receives the Shopify order JSON and generates a PDF invoice through TemplateMaster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from "express";
import axios from "axios";

const app = express();
app.use(express.json());

app.post("/webhooks/shopify/order-created", async (req, res) =&amp;gt; {
  const order = req.body;

  try {
    // Call TemplateMaster to generate a PDF + send email
    await axios.post(
      "https://api.templatemaster.fr/generate/pdf-email",
      {
        templateId: "your-invoice-template-id",
        data: order, // You can remap fields if needed
        email: {
          to: order.email,
          subject: `Invoice for Order #${order.name}`
        }
      },
      {
        headers: {
          "X-API-KEY": process.env.TM_API_KEY
        }
      }
    );

    res.status(200).send("OK");
  } catch (err) {
    console.error(err);
    res.status(500).send("Error");
  }
});

app.listen(3000, () =&amp;gt; console.log("Server running"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Example in C# (.NET)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System.Net.Http;
using System.Text;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-KEY", "YOUR_API_KEY");

app.MapPost("/webhooks/shopify/order-created", async (Order order) =&amp;gt;
{
    var requestBody = new
    {
        templateId = "your-invoice-template-id",
        data = order,
        email = new
        {
            to = order.email,
            subject = $"Invoice for Order {order.name}"
        }
    };

    var json = System.Text.Json.JsonSerializer.Serialize(requestBody);
    var content = new StringContent(json, Encoding.UTF8, "application/json");

    await client.PostAsync("https://api.templatemaster.fr/generate/pdf-email", content);

    return Results.Ok();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Template Structure (Invoice Example)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inside your TemplateMaster HTML template, simply use JSON placeholders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Invoice – Order {{name}}&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Date: {{created_at}}&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;Customer: {{customer.first_name}} {{customer.last_name}}&amp;lt;/p&amp;gt;

&amp;lt;table&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;th&amp;gt;Item&amp;lt;/th&amp;gt;
    &amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;
    &amp;lt;th&amp;gt;Price&amp;lt;/th&amp;gt;
  &amp;lt;/tr&amp;gt;

  {{#each line_items}}
  &amp;lt;tr&amp;gt;
    &amp;lt;td&amp;gt;{{title}}&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;{{quantity}}&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;{{price}}&amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
  {{/each}}
&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;Total: {{total_price}} {{currency}}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TemplateMaster automatically applies your CSS and returns a beautiful PDF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Bonus Features You Can Add&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✔️ Send emails to the store owner&lt;br&gt;
✔️ Send packing slips to warehouse staff&lt;br&gt;
✔️ Add customer notes, discount codes, fulfillment info&lt;br&gt;
✔️ Save PDFs to your storage (S3, Azure, etc.)&lt;br&gt;
✔️ Use multiple templates depending on order type&lt;/p&gt;

&lt;p&gt;🎉 Conclusion&lt;/p&gt;

&lt;p&gt;With just a few lines of code, you can fully automate:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PDF invoice generation&lt;br&gt;
Order confirmation emails&lt;br&gt;
Document storage&lt;br&gt;
Multi-store workflows&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Using Shopify Webhooks + TemplateMaster API is a powerful way to build scalable, automated document flows without maintaining your own rendering engine.&lt;/p&gt;

&lt;p&gt;👉 Try it now: &lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;https://templatemaster.fr&lt;/a&gt;&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>webhooks</category>
      <category>ecommerce</category>
      <category>saas</category>
    </item>
    <item>
      <title>How to Generate PDFs via API in C# (using TemplateMaster)</title>
      <dc:creator>TemplateMaster</dc:creator>
      <pubDate>Tue, 09 Dec 2025 15:07:39 +0000</pubDate>
      <link>https://dev.to/templatemaster/how-to-generate-pdfs-via-api-in-c-using-templatemaster-47gm</link>
      <guid>https://dev.to/templatemaster/how-to-generate-pdfs-via-api-in-c-using-templatemaster-47gm</guid>
      <description>&lt;p&gt;✨ Introduction&lt;/p&gt;

&lt;p&gt;Generating PDFs dynamically in a C# application is a common need: invoices, quotes, certificates, contracts…&lt;br&gt;
But implementing your own PDF engine is painful — libraries are heavy, HTML rendering is inconsistent, and templates are hard to maintain.&lt;/p&gt;

&lt;p&gt;That's why I built TemplateMaster, a simple API-based service that lets you generate PDF documents from templates using clean JSON data.&lt;/p&gt;

&lt;p&gt;In this article, I’ll show you how to generate a PDF from C# in just a few lines of code.&lt;/p&gt;

&lt;p&gt;🔧 Step 1 — Add your configuration in appsettings.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "TemplateMaster": {
    "ApiKey": "YOUR_API_KEY_HERE",
    "BaseUrl": "https://api.templatemaster.fr"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔨 Step 2 — Create a TemplateMaster API client&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TemplateMasterClient
{
    private readonly HttpClient _http;
    private readonly string _apiKey;

    public TemplateMasterClient(HttpClient http, IConfiguration config)
    {
        _http = http;
        _apiKey = config["TemplateMaster:ApiKey"];

        _http.BaseAddress = new Uri(config["TemplateMaster:BaseUrl"]);
        _http.DefaultRequestHeaders.Add("X-API-KEY", _apiKey);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This client automatically injects the API key into every request.&lt;/p&gt;

&lt;p&gt;📄 Step 3 — Generate a PDF&lt;/p&gt;

&lt;p&gt;Endpoint used:&lt;br&gt;
&lt;code&gt;POST /documents/generate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;C# method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public async Task&amp;lt;byte[]&amp;gt; GenerateDocument(string templateId, object model)
{
    var request = new
    {
        TemplateId = templateId,
        Data = model
    };

    var response = await _http.PostAsJsonAsync("/documents/generate", request);
    response.EnsureSuccessStatusCode();

    var result = await response.Content.ReadFromJsonAsync&amp;lt;Dictionary&amp;lt;string, string&amp;gt;&amp;gt;();
    var fileUrl = result["FileUrl"];

    return await _http.GetByteArrayAsync(fileUrl);
}

▶️ Usage example
var pdf = await _templateMaster.GenerateDocument("invoice-template", new {
    Customer = "John Doe",
    Amount = 120.50,
    Date = DateTime.Now.ToString("yyyy-MM-dd")
});

await File.WriteAllBytesAsync("invoice.pdf", pdf);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚀 Try TemplateMaster&lt;/p&gt;

&lt;p&gt;You can test the API for free here:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;TemplateMaster&lt;/a&gt;&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>csharp</category>
      <category>pdf</category>
      <category>dotnet</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Automate Document &amp; Email Generation in Your Apps with TemplateMaster</title>
      <dc:creator>TemplateMaster</dc:creator>
      <pubDate>Sat, 08 Nov 2025 09:48:58 +0000</pubDate>
      <link>https://dev.to/templatemaster/automate-document-email-generation-in-your-apps-with-templatemaster-1p95</link>
      <guid>https://dev.to/templatemaster/automate-document-email-generation-in-your-apps-with-templatemaster-1p95</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2j5wyxgdx0b4arph7s3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2j5wyxgdx0b4arph7s3.gif" alt=" " width="600" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Creating, sending, and managing documents and emails is often repetitive and error-prone, especially when working with multiple templates and formats. TemplateMaster is a SaaS platform that allows developers and teams to automate document and email generation using a simple API and an intuitive editor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why TemplateMaster?&lt;/strong&gt;&lt;br&gt;
With TemplateMaster, you can:&lt;/p&gt;

&lt;p&gt;Create dynamic templates with HTML/CSS and a live PDF preview.&lt;/p&gt;

&lt;p&gt;Automate email sending directly from your templates or via APIs.&lt;/p&gt;

&lt;p&gt;Store documents securely, or integrate with external storage like AWS S3 or Cloudflare R2.&lt;/p&gt;

&lt;p&gt;Add metadata and document indexes for advanced search or document management (GED).&lt;br&gt;
Advanced Features&lt;/p&gt;

&lt;p&gt;SMTP Configuration: Connect multiple SMTP servers and define a default one.&lt;/p&gt;

&lt;p&gt;Webhooks: Automatically send generated documents to external applications or storage.&lt;/p&gt;

&lt;p&gt;Metadata &amp;amp; Indexing: Add PDF metadata and structured indexes for enterprise document management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
TemplateMaster simplifies the repetitive parts of document and email handling for developers. By integrating the API, you can focus on your core application logic while ensuring reliable, professional documents and emails.&lt;/p&gt;

&lt;p&gt;Try it today: &lt;a href="https://templatemaster.fr" rel="noopener noreferrer"&gt;https://templatemaster.fr&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Repository: [&lt;a href="https://github.com/Moukouk/TemplateMaster" rel="noopener noreferrer"&gt;https://github.com/Moukouk/TemplateMaster&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>emailtemplates</category>
      <category>documentautomation</category>
      <category>saas</category>
      <category>visualtemplateeditor</category>
    </item>
  </channel>
</rss>
