Skip to content

Templates and workspace files

A template is a document layout that you keep in your workspace and fill with data each time you render. You edit its draft in Studio, preview it with sample data, and publish it as a numbered version that your applications render. To build one step by step, start with build a template.

CreateDraftwhat you editsavepreviewpublishRevisions 2, 3…each save is keptPreviewPDF, XLSX or HTML; nothing savedVersion 1, 2…frozen and self-containedrenderPDF / XLSX

Create a template in Studio’s explorer with New entity → Template (in the + menu or a folder’s … menu). In the Add template dialog, Start with decides its kind. It starts on Blank page, a visual template that opens in the visual editor. Code: HTML or Excel opens a second choice, Code template, for templates written as code:

Start with Source file Renders Learn more
Blank page, Ready-made starter or Layout from JSON data composition.json PDF Visual editor
PDF file, drafted with AI composition.json or template.html PDF From a PDF
Code: HTML, blank page or Invoice example template.html PDF Handlebars templates
Code: HTML file (upload one, up to 1 MB) template.html PDF Handlebars templates
Code: Excel workbook (XLSX) template.html and the uploaded .xlsx XLSX Spreadsheet templates
Code: Spreadsheet (XLSX and PDF tables) sheets.json XLSX or PDF Spreadsheet templates

A template has exactly one source, and the source decides what it can render. A visual template’s composition.json is a tree of components, which you can also write as JSON or create through the API. Ready-made starter, Layout from JSON data, Invoice example and Spreadsheet also create a sample.json data file beside the template (in a new folder named after the template when you create it at the workspace root).

PDF file, drafted with AI turns a PDF you already send, such as an invoice from your current system, into a template that looks like it. Upload a PDF of up to 10 MB and 10 pages, without a password, and choose under Draft as what to get: a Visual template, the default, to edit on the page, or an HTML template to edit as code. HTML drafts tend to match the PDF a little more closely.

  1. Claude, Anthropic’s AI, reads the PDF and writes a draft: a composition.json or template.html with the layout and fixed text, and a sample.json with the values that change from one document to the next.
  2. Typefold renders the draft, compares it with your PDF page by page and sends the differences back, a few times, until the draft matches closely.
  3. The best draft opens as a template in a new folder named after it, with sample.json and the PDF’s raster images beside it: a visual template in the visual editor, an HTML one in its tab. Edit it like any other template, then publish it.

It usually takes two to five minutes; you can close the window meanwhile. Fonts are replaced with Arial, and vector logos and icons are redrawn as simple shapes or left as a box of the same size, so upload your fonts and logo afterwards.

The PDF and the images of each draft go to Anthropic; Typefold doesn’t keep the PDF. On the hosted service, see the privacy policy. On your own installation, the choice shows once an ANTHROPIC_API_KEY is set.

Each plan allows a number of templates from a PDF a month, listed under render allowances. See what is left under Settings → Render limits.

A template’s tab in Studio shows its source on top and its other files in tabs below it. An Export folder zip holds each of them as a file.

Studio tab File What it holds
Source (top) template.html, sheets.json or composition.json The body of the document.
helpers.js helpers.js Your JavaScript helpers. HTML templates only; see Handlebars templates.
Page header header.html Handlebars drawn in the top margin of every page. Not for spreadsheet templates.
Page footer footer.html Handlebars drawn in the bottom margin of every page. Not for spreadsheet templates.
page.json page.json Paper, margins, language and PDF options; see page.json.
fields.json fields.json The content fields a content editor may change.
content.json content.json The values of those fields.
  • The Page header, Page footer, fields.json and content.json tabs show once they have content. Add them with the + (Add a file) at the end of the tab bar. Page numbers and the other header and footer markup are in build a template.
  • A visual template opens in the visual editor. Code in the editor switch opens the same template in these tabs; see switch to code.
  • HTML templates also have a Bindings tab, which lists every placeholder in the HTML and the value the sample data gives it.
  • Everything else a template uses is a workspace file that it names by path. The preview toolbar sets three of them:
    • Data: the sample data file previews render with. Pick one in or under the template’s folder.
    • Template files (the folder icon): the stylesheets the template applies and the beforeRender scripts it runs, in the order you tick them. Up to 20 stylesheets and 10 scripts.
    • Workbook, for an Excel workbook template: the .xlsx file it fills.

page.json sets the template’s paper and the PDF’s defaults. Edit it in the page.json tab, or use PDF properties in the preview toolbar, which edits the same settings in a form.

page.json
{
"pageSize": { "widthMm": 210, "heightMm": 297 },
"orientation": "portrait",
"margins": { "topMm": 15, "rightMm": 15, "bottomMm": 20, "leftMm": 15 },
"locale": "en-GB",
"metadata": { "title": "Invoice {{invoice.number}}" }
}
Setting Default What it does
pageSize Required. widthMm and heightMm, each above 0 and up to 2,000.
orientation portrait portrait or landscape.
margins Required. topMm, rightMm, bottomMm and leftMm, each 0 to 500.
locale en-US The template’s language: picks the translation file and sets the PDF’s language. See translations.
pageRanges Pages to keep, such as 1-5, 8, 11-. Page numbers still count the whole document.
metadata PDF properties such as title, author and subject. Values may use {{path}} placeholders. See PDF standards and security.
encryption Passwords and permissions. Passwords may use {{path}} placeholders. See PDF standards and security.
signature Sign with a workspace signing certificate. See PDF standards and security.
operations Up to 10 steps that add another template’s pages before or after this one, or draw them onto it. See combine templates.
pdfa The PDF/A level to write and check. See PDF standards and security.
pdfua The PDF/UA part to write and check. See PDF standards and security.
opaqueFills true draws see-through content (CSS opacity, translucent colours) at full strength. Shown in PDF properties as Ignore opacity.
preferCssPageSize true prints on the paper a CSS @page { size } rule names instead of pageSize. See supported CSS.

A Reports API request or a preview can override most of these for one render.

Templates and workspace files sit together in one tree of folders in Studio’s explorer. One file can be used by many templates, so a shared stylesheet or logo is edited in one place. Create a file with New entity and the kind below, or drop files into Import…:

New entity Default name Holds
Sample data data.json Data for previews. Must be valid JSON. Production renders use the data you send instead.
Localization en.json Translation labels, named for a language tag such as de-CH.json. See translations.
Component component.html A reusable piece of Handlebars (a partial), used with {{> name}} or {{component "path"}}.
Script shared-helpers.js A beforeRender script. See Handlebars templates.
Stylesheet shared-styles.css CSS, ticked under Template files or included with {#asset}.
Asset the uploaded name An uploaded font, image, .xlsx workbook or PDF file.
  • Names are unique within a folder, ignoring case.
  • A file’s header in Studio shows Used by with the templates that use it, and their live version. Saving a shared file saves it straight to the workspace; it has no draft of its own.
  • Download in a file’s header saves it as a file. An uploaded file’s page also shows its Asset ID, which component templates name images and fonts by.
  • In the explorer, Clone, Cut, Copy and Paste copy or move templates, files and folders. A copy of a template is a new template that has not been published.
  • Size and count limits are in limits.

A template names a file by its path, such as styles/invoice.css. Keep a template’s files in its folder or in subfolders of it.

Reference Example Where it looks
Partial {{> lines}} The referencing file’s folder, then its partials subfolder. Also tries .hbs, .html and .handlebars.
Component {{component "components/row.html"}} The referencing file’s folder, then the template’s folder.
Include {#asset styles/theme.css @encoding=utf8} The referencing file’s folder, then the template’s folder. Includes can nest.
Embedded font or image {#asset fonts/brand.ttf @encoding=dataURI} As for an include.
HTML src, CSS url() src="./images/logo.svg" The referencing file’s folder.
Data, Template files, Workbook sample.json The template’s folder.
Translation files de-CH.json The template’s folder and its localizations subfolder.
  • In a {#asset} or {{component}} path, a leading / starts at the workspace root.
  • ../ goes up a folder; above the root it stays at the root.
  • Folder and file names match ignoring case.
  • Quote paths that contain spaces or parentheses: url("../Client (2)/logo.png"), {#asset "../Client (2)/theme.css" @encoding=utf8}.
  • An {#asset} path may end in Handlebars, such as {#asset ./icons/{{icon}}.svg @encoding=dataURI}. Publishing then copies every uploaded file directly in that folder (./icons, not its subfolders) into the version.
  • A src or url() value without a / that starts with no . and matches no file is left as it is.

Renaming or moving a file, folder or template never rewrites the paths that point to it. Saving does not check paths; previewing and publishing do. A missing file, or a file of the wrong kind (such as a font included with @encoding=utf8), fails with 400 ASSET_INVALID and lists each path with the file that names it. Files that include each other in a loop fail with 400 BAD_REQUEST.

The draft is what you edit. Save in the editor header (or Ctrl+S, Cmd+S on a Mac) saves it as a new revision. Revision 1 is the template as it was created or imported, and every save adds one. Revisions cannot be changed or deleted.

History in the editor header opens the template’s review on Compare, showing any two revisions or versions file by file, including which data, stylesheets and scripts the template used. Switch Show changes as from Code to Pages to see the same two as rendered pages. Restore makes the Before side the latest draft; the draft it replaces stays a revision.

The header shows who else has the template or file open: in the code editor, the visual editor or the content form, and whether they have unsaved changes. A newer draft someone else saved loads on its own while you have no unsaved changes. With unsaved changes, nothing is replaced unseen: the header says who saved the newer version and offers Compare, which shows their version beside yours file by file, Load theirs, which drops your changes, and Save mine over theirs. The replaced version stays in History.

Update preview renders what is in the editor, unsaved edits included, with the sample data file chosen in Data. Nothing is saved or published.

  • Output switches between XLSX and PDF for a spreadsheet template.
  • Preview picks one of the template’s translation languages for this preview only. It shows once the template has a translation file.
  • The Profiler tab shows how long the render took and any console.log output from helpers and scripts.
  • Check accessibility and conformance checks the PDF against PDF/A and PDF/UA. See PDF standards and security.
  • Shared files render as last saved. An unsaved sample data file open in another tab is the exception: the preview uses its text as it is.

A PDF preview counts against your render allowances like any render. An XLSX preview does not count, but it is refused while the allowances are used up. See limits. Through the API, a preview can also return the filled HTML before PDF layout; see the API reference.

Publish in the editor header publishes the saved draft as the template’s next version: 1, 2, 3 and so on. In the code editor, save first: Publish is unavailable while there are unsaved changes. The visual editor saves your edits before it publishes. Publish is also unavailable when the saved draft is already live. The status beside the template’s name shows where it stands:

Status Meaning
Unsaved changes The editor holds edits that are not saved.
Saved · not published The template has never been published.
Saved · changes since v2 The saved draft differs from the live version 2.
Published v2 The saved draft is live as version 2.

Publishing copies into the version every file the template uses at that moment: partials, stylesheets, scripts (including folder and workspace-wide ones), translations, sample data, fonts, images and the workbook. It does not render the template, so preview first.

  • Editing the draft or a shared file changes the next preview and the next publish of every template that uses it.
  • A version keeps its own copy of every file. What your applications render does not change until you publish again, and deleting or editing a file never breaks a version.
  • Versions cannot be changed or deleted.
  • A version freezes your template, not Typefold itself. An upgrade of Typefold that fixes layout can change the output of an existing version.

Renders by name use the latest published version. The Reports API returns the file in its response, and the Renders API renders in the background and can also render one specific version.

Click Use from code in the editor’s header, or choose it in a template’s … menu in the explorer. Under Task, the dialog has ready requests for this template:

  • Render it: renders the published version by the template’s name and saves the PDF, in curl, .NET, TypeScript, JavaScript and Python, with the command that installs each client library. It sends the template’s own sample data: the published version’s, or before the first publish, the draft’s sample data file. Replace it with your data. If another template has the same name, the request names this one by its ID instead. A template that is not published yet has a Publish button here.
  • Read its draft, Update its draft and Publish its draft: the HTTP requests that change the template from a script, in curl.

Each request needs an API key from the same workspace. Owners and admins can click Create API key under the render request: the new key, allowed to render, goes into the code. Copy it then, as it is not shown again.

In the explorer, click + → Import…, or Import into folder… in a folder’s … menu, then drop files or a folder:

You drop Studio
A project folder Creates a new template, in a folder of its own, from the HTML and its files.
A .zip made by Export folder or Export workspace Updates the folders, files and templates it holds, and creates the rest. See deploy across environments.
A report archive from another tool Imports its templates. See migrating.
Other files Adds them to the folder: .css as a stylesheet, .js as a script, .html as a component, a language-named .json as a translation, other .json as data, anything else as an asset.

A project folder has exactly one .html file and at most one .js helpers file at the top level, optional .css files, optional data/, localizations/ and partials/ folders, and images (.png, .jpg, .svg) and fonts (.woff2, .ttf, .otf) in named folders such as fonts/. It holds at most 245 files and 10 MB. Imported templates arrive as drafts: preview them, then publish each one.

Choose Delete in a template’s, file’s or folder’s … menu in the explorer. To delete several at once, tick their checkboxes (or choose Select in a menu), then click Delete selected.

  • Deleting a folder deletes everything in it. It is refused while a template or file outside the folder still uses one of its files.
  • A workspace file is refused while a template or another file still names it. The message lists each one; change those paths first.
  • There is no undo. New renders of a deleted template fail with 404 NOT_FOUND, including renders by name. Files already rendered are kept.

Everything on this page can also be done through the API, for example from a build script: create templates, save drafts, read revisions, preview, publish, manage folders and files, and import or export a zip. Reading needs the template:read scope, changing template:write, and publishing template:publish; uploading fonts and images also needs asset:manage. See the API reference for every endpoint and field, and the HTTP API for keys and errors.