Templates and rendering

The template

A template is a JSON document (format erd-report-template, templateVersion 1) with pages in points. A page holds elements with a fixed frame and optional bands. Values and formulas are expression strings, and templates never contain code. A JSON Schema of the format ships with the designer for validation and editor completion.

Images are embedded as data URIs; URLs and file paths in a template are never fetched. Fonts are named by family from the ERD-Report Cloud font set.

Output formats of the render API

FormatResult
pdfA PDF with every page.
docxA Word document.
xlsxAn Excel workbook with typed cells and native charts. Options in options.xlsx; an optional password encrypts it.
htmlA complete, self-contained web page: real text, charts as inline SVG, images and fonts embedded, no script. Options in options.html (mode paged or flat); show it in a sandboxed frame.
png, jpeg, webpOne page rasterised, with page, dpi and quality options.
zpl, tspl, epl2, dymoLabel bytes for label templates.
escposReceipt bytes (ESC/POS) for receipt templates whose target.receiptLanguage is escpos. X-Render-Target gives the language and the head density.

A render request

POST /v1/render
Authorization: Bearer erd_live_...
Content-Type: application/json
Idempotency-Key: invoice-1042-v1

{
  "template": { "...": "the parsed documentJson()" },
  "data": { "rows": [ { "sku": "A-100", "qty": 2, "total": 19.90 } ] },
  "format": "pdf"
}

An XLSX request

POST /v1/render
Authorization: Bearer erd_live_...
Content-Type: application/json
Idempotency-Key: invoice-1042-xlsx-v1

{
  "template": { "...": "the parsed documentJson()" },
  "data": { "rows": [ { "sku": "A-100", "qty": 2, "total": 19.90 } ] },
  "format": "xlsx",
  "options": {
    "xlsx": {
      "exportMode": "singleFilePageByPage",
      "sheetName": "Invoice",
      "author": "Accounts"
    }
  }
}

A password-protected workbook

// Node, on your server. The password comes from the environment, never from the page.
const response = await fetch(`${process.env.ERD_REPORT_BASE_URL}/v1/render`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ERD_REPORT_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'invoice-1042-xlsx-v2',
  },
  body: JSON.stringify({
    template,
    data,
    format: 'xlsx',
    options: {
      password: process.env.WORKBOOK_PASSWORD,
      encryptionType: 'strong',
    },
  }),
});
const workbook = Buffer.from(await response.arrayBuffer());

An HTML request

POST /v1/render
Authorization: Bearer erd_live_...
Content-Type: application/json
Idempotency-Key: invoice-1042-html-v1

{
  "template": { "...": "the parsed documentJson()" },
  "data": { "rows": [ { "sku": "A-100", "qty": 2, "total": 19.90 } ] },
  "format": "html",
  "options": {
    "html": {
      "mode": "flat",
      "pageRange": "1,3-5",
      "classPrefix": "inv",
      "title": "Invoice 1042"
    }
  }
}

Showing an HTML report safely

// Node, on your server. The document is data from outside your site: serve it as a resource of its own,
// under the policy the service sent, and show it in a sandboxed frame.
const response = await fetch(`${process.env.ERD_REPORT_BASE_URL}/v1/render`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ERD_REPORT_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'invoice-1042-html-v2',
  },
  body: JSON.stringify({ template, data, format: 'html', options: { html: { mode: 'flat' } } }),
});
const policy = response.headers.get('Content-Security-Policy');
if (!response.ok || !policy) throw new Error('no document, or no policy to serve it under');

res.writeHead(200, {
  'Content-Type': 'text/html; charset=utf-8',
  'Content-Security-Policy': policy,
  'X-Content-Type-Options': 'nosniff',
  'Referrer-Policy': 'no-referrer',
});
res.end(await response.text());

// In your page (not in the document itself):
//   <iframe sandbox src="/reports/invoice-1042" title="Invoice 1042"></iframe>
Keep the API key on your server:

Rendering through ERD-Report Cloud needs an API key, and that key is a server secret. Never call the render API from the browser or ship the key in a page: the browser talks to your server, and your server talks to ERD-Report Cloud. Rendering with the ERD-Report Renderer inside your own process keeps the request local altogether, and its licence token is a server secret in exactly the same way.

Same bytes wherever it is rendered:

Designer templates render on ERD-Report Cloud, and the Renderer and the Server are that same engine over the same request format. So the same template and the same data give the same document — the same SHA-256 — whether the Cloud draws it, a binary inside your own process, or a container inside your own network.

It is measured, not claimed: a 54-request corpus in 12 formats, three runs per build, across glibc, musl and ARM64, produced identical document bytes and zero differing pixels in 45 image and PDF-page comparisons; encrypted workbooks decrypt to the same plaintext while their ciphertexts differ, as encryption must. (Measured on Linux x64 and emulated ARM64 — native Windows and macOS builds are not part of that measurement yet.)

Print through ERD-Hub

Pages that embed the designer can also print to the printers on the visitor's own computer through ERD-Hub. ERD-Hub is free to use with the designer, and its client ships with the designer package.

Frequently asked questions

Does the designer render PDFs in the browser?

No. The browser script designs and previews templates; the document itself is drawn on your server by one of three ERDesigns products: ERD-Report Cloud as a hosted service with an API key, the ERD-Report Renderer as one binary inside your own process, or the ERD-Report Server as a container in your own infrastructure.

What does the designer cost?

The designer is for embedding in your own website and is not charged for separately.

Rendering is a product of its own: ERD-Report Cloud is the hosted service, with plans and an API key. The ERD-Report Renderer and the ERD-Report Server are licensed per customer, per year, and the renderer has a Free edition for personal use and evaluation.

Do I get the renderer?

Yes. The ERD-Report Renderer is the same engine as one static binary in your own process: a request on stdin, the document on stdout. Its Free edition covers personal use and evaluation with every output format enabled and no watermark; Standard and Enterprise licences cover commercial use. The ERD-Report Server is that same engine as a container in your own infrastructure and is licensed the same way. ERD-Report Cloud stays the hosted option, with plans and an API key.

Can I get a free trial for ERD-Report Cloud?

Yes. Contact ERDesigns to request a trial of ERD-Report Cloud and see what it does for your application. If the data may not leave your own machine, the renderer's Free edition is the way to try the same engine instead.

Do I need a framework or a bundler?

No. The designer is one classic script and one stylesheet with no dependencies. Applications with a bundler or written in TypeScript can use the package build instead.

Can I restyle the designer?

Yes. The chrome is restyled through CSS variables, the canvas through colour tokens for light and dark mode, and the composition option hides the tools you do not want to offer.

Where are templates stored?

In your application. The designer returns the template as JSON and imposes no storage backend.

Which browsers are supported?

Evergreen Chromium, Firefox and Safari.

Can the designer design labels?

Yes. A template carries a target of paper, label or receipt. A label targets ZPL, TSPL, EPL2 or DYMO with the label stock and print head density; a receipt is a kind of its own and targets an ESC/POS receipt printer with the roll width, the print head density and the cut. The same embedding mounts as a label designer or as a receipt designer.

Search all ERD-Report Designer help topics