Forma PDF

Save PDF templates as JSON in your database

By WVSTECH · Reviewed November 23, 2026 · Examples target SDK 0.4.0

Store the original layout JSON as a template record and pass fresh business data each time a document is generated. You do not need to save a separate layout for every customer.

A practical database record

{
  "id": "quotation-standard",
  "revision": 3,
  "ownerId": "workspace-example",
  "layout": { "schemaVersion": 1, "name": "Quotation", "page": {}, "pages": [] }
}

This is a storage envelope, not a complete renderable layout. Replace the layout placeholder with editor.getEstruct(). Keep your record ID and revision outside the SDK layout, and preserve page IDs, field IDs and page order inside it.

Load and generate

const template = await loadAuthorizedTemplate(templateId)
const customerData = await loadAuthorizedQuotation(quotationId)
const pdf = await generatePDF(template.layout, customerData)

Both load functions belong to your application. Enforce workspace ownership on the server; hiding a template in the UI is not authorization. Save edits through an explicit action or a debounced draft handler. For concurrent authors, use a revision check so an older browser tab cannot silently overwrite a newer template.

Do I save automatic pages?

Save the original layout rather than the calculated result of resolveDocument. Automatic pages depend on current values, text lengths and table rows. Recalculate them when you generate the next document.

Continue building

Try the visual editor View the SDK license