Document Generation SDK

Document generation SDK for Node.js and Python

Install one package, send a template and your data, and get a finished PDF back. The SDK takes care of retries, long renders and webhook signatures.

  • 50 free renders/month
  • No credit card
  • MIT-licensed packages

What is a document generation SDK?

A document generation SDK is a package you install in your application to create documents from data. You call a function with a template and your JSON, and get a finished PDF or image back. Our SDKs are clients for a hosted API: rendering happens on our servers, so you don’t install or run a browser.

Document generation SDK key facts
LanguagesTypeScript and JavaScript, Python. Every other language can call the REST API
Installnpm install @dynamic-document-api/sdk or pip install dynamic-document-api
Runs onNode.js 18 and later, Deno, Bun and edge runtimes; Python 3.9 and later, with a synchronous and an asyncio client
DependenciesNone for TypeScript; httpx and typing_extensions for Python
InputStored templates, HTML, a URL or Markdown, plus your data as JSON
OutputPDFs, images and e-invoices (Factur-X/ZUGFeRD and XRechnung)
LicenseMIT. Both packages are at version 0.2, so a minor version can still change method names
PriceFree: 50 renders/month. Paid from €15/month (billed annually) for 3,000 renders

Your first PDF, in one file

This is the whole program. It fills an HTML template with data, adds page numbers and writes invoice.pdf. Create an API key in the dashboard and set it as DYNAMIC_DOCUMENT_API_KEY. A test key is free and adds a TEST watermark.

import { writeFile } from "node:fs/promises";
import { DynamicDocumentApi } from "@dynamic-document-api/sdk";

const dda = new DynamicDocumentApi(); // reads DYNAMIC_DOCUMENT_API_KEY

const pdf = await dda.renders.createBinary({
  input: {
    type: "html",
    html: `<h1>Invoice {{ number }}</h1>
      <table>{% for item in items %}
        <tr><td>{{ item.name }}</td>
            <td>{{ item.price | format_currency("USD", "en-US") }}</td></tr>
      {% endfor %}</table>`,
  },
  data: {
    number: "2026-0042",
    items: [
      { name: "Consulting", price: 1200 },
      { name: "Hosting", price: 80 },
    ],
  },
  output: {
    format: "pdf",
    pdf: {
      paper: { size: "Letter" },
      footer: { enabled: true, right: "Page {{page}} of {{pages}}" },
    },
  },
});

await writeFile("invoice.pdf", await pdf.bytes());
from pathlib import Path
from dynamic_document_api import DynamicDocumentApi

dda = DynamicDocumentApi()  # reads DYNAMIC_DOCUMENT_API_KEY

pdf = dda.renders.create_binary(
    input={
        "type": "html",
        "html": """<h1>Invoice {{ number }}</h1>
          <table>{% for item in items %}
            <tr><td>{{ item.name }}</td>
                <td>{{ item.price | format_currency("USD", "en-US") }}</td></tr>
          {% endfor %}</table>""",
    },
    data={
        "number": "2026-0042",
        "items": [
            {"name": "Consulting", "price": 1200},
            {"name": "Hosting", "price": 80},
        ],
    },
    output={
        "format": "pdf",
        "pdf": {
            "paper": {"size": "Letter"},
            "footer": {"enabled": True, "right": "Page {{page}} of {{pages}}"},
        },
    },
)

Path("invoice.pdf").write_bytes(pdf.content)

For a layout you use every day, store it as a versioned PDF template and send only its ID and the data. Keep the API key on your server: the SDK isn’t meant for browser code.

What the SDK does for you

Everything here also works with plain HTTP. With the SDK you don’t have to write and test it yourself.

Retries that never bill twice

Network errors, 429 and 5xx responses are retried with growing pauses. Every POST carries an idempotency key, so a retry returns the first render instead of making a second one. You can set your own key, such as the invoice number.

await dda.pdf.fromHtml({ html }, {
  idempotencyKey: `invoice-${id}`,
});

Errors that name the line

A failed render throws a RenderFailedError that says what’s wrong and where in your template. The comment below is the real message for a misspelled filter.

if (error instanceof RenderFailedError)
  console.error(error.message);

// unknown filter: filter currency is
// unknown (in body.html, line 2)

Waiting for long documents

Start a long report in the background and let waitForRender check until it’s finished. Your code doesn’t need its own polling loop.

const job = await dda.renders.create({
  input: { type: "html", html },
  data,
  output: { format: "pdf" },
  mode: "async",
});
const done = await dda.waitForRender(job.id);

Webhooks you can trust

Get a webhook when a document is ready. verify checks the signature and the timestamp, and throws an error if the body was changed.

const event = await dda.webhooks.verify(
  rawBody, request.headers, secret,
);
if (event.type === "render.succeeded")
  console.log(event.data.object.id);

Invoices, reports and certificates with the SDK

The examples use TypeScript. The Python methods have the same names in snake case, for example from_template.

PDF invoices

Send the invoice data, get the PDF. The same call can return a Factur-X or ZUGFeRD e-invoice on the Growth plan and up. More on the invoice PDF API.

const invoice = await dda.pdf.fromTemplate({
  templateId: "tpl_…",
  data: { number: "2026-0042", customer, items },
});

PDF reports

Charts, long tables with repeating headers, bookmarks and page numbers. The details are on the report generation API page.

const report = await dda.pdf.fromTemplate({
  templateId: "tpl_…",
  data: { client: "Acme Co.", period, rows },
  pdf: { outline: true, tagged: true },
});

Certificates for a whole course

Send one list of participants and get one PDF each, all in one ZIP file. Batches need a paid plan. See certificate generation.

const batch = await dda.batches.create({
  templateId: "tpl_…",
  items: people.map((person) => ({ data: person })),
  combine: { zip: true },
});
await dda.waitForBatch(batch.id);

Put finished PDFs together

Merge a cover letter, a report and an appendix into one file. The SDK also splits, rotates and protects PDFs.

const file = await dda.pdfTools.merge({
  sources: [
    { renderId: cover.id },
    { renderId: report.id },
  ],
});

SDKs for Node.js, Python, .NET and other languages

We have official SDKs for two languages today. For the others, you call the REST API with the HTTP client you already use.

SDKs for Node.js, Python, .NET and other languages
Language How to connect Start here
Node.js, TypeScriptSDK on npmHTML to PDF in Node.js
PythonSDK on PyPIHTML to PDF in Python
C# and .NETREST API with HttpClient; an SDK is plannedHTML to PDF in C#
PHPREST API; an SDK is planned nextPHP example on the HTML to PDF API page
Java, Go, RubyREST API; SDKs are planned after PHPAPI reference
No coden8n, Zapier and MakeAll integrations

SDK or PDF library?

A PDF library runs inside your application. Our SDK sends the work to a hosted service. Both are good choices for different projects.

PDF library compared with the Dynamic Document API SDK
Question PDF library Dynamic Document API SDK
Where the PDF is madeIn your applicationOn our servers in Germany
How you design the pageDepends on the library: code, or HTML with varying CSS supportHTML and CSS, rendered in Chromium
What you operateThe library, and often a browser with its updatesNothing beyond the package
Works offlineYesNo
Data leaves your networkNoYes: the data is sent to the API
Best whenData must stay with you, or you draw simple pages in codeDocuments must look like your design, in any number, without running a browser

We ran the same invoice through the common libraries and published every PDF: JavaScript, Python and .NET.

What it costs

Free

€0

50 renders per month. Enough to build and test your first document.

Starter

€15 / month

3,000 renders per month, billed annually (€19 billed monthly). About €0.005 per document.

The SDKs themselves are free. You pay for renders, and one render is one returned file of up to 50 pages. Test renders don’t count. See all plans and prices.

FAQ

Document generation SDK: frequently asked questions

Which document generation APIs have an SDK for Node.js, Python and .NET?

Dynamic Document API has official SDKs for Node.js (TypeScript and JavaScript) and Python. There is no .NET SDK yet. From C# you call the REST API with HttpClient, and a complete example with retries is in our C# tutorial.

Does the SDK create the PDF on my server?

No. The SDK sends your template and data to our API, which renders the document and returns the file. You don’t need Chrome, fonts or a queue on your side. If data must never leave your network, use a PDF library instead.

Do I need a template before I can start?

No. You can send HTML straight from your code, as in the first example on this page. A stored template makes sense once you use the same layout often or want colleagues to edit it without a deployment.

How do I generate certificates with the SDK?

Store the certificate as a template with fields for the name, course and date. Then pass the list of participants to batches.create. You get one PDF per person and, if you want, all of them in one ZIP file. Batches are part of the paid plans.

Can I use the SDK in the browser?

Keep it on your server, because the API key would be visible to every visitor. If a web page or email has to show a generated image, create a signed link: it works without the key and only allows the fields you choose.

What if the SDK doesn’t cover an endpoint?

Call it with dda.request(). It reaches every endpoint of the API and uses the same authentication, retries and error handling.

Create your first document free

50 renders a month on the free plan, no credit card.

Start free