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
- Add PDF templates to a Bolt or Lovable project
- Generate a PDF from JSON in the browser
- Embed a visual PDF template editor in JavaScript
- Integrate a PDF editor with React and Next.js
- Create editable PDF templates in Bubble workflows
- Automatic PDF page breaks for text and tables
- Build a quotation PDF generator for your application
- Create a restaurant menu PDF from structured data
- Generate internal documents and memos from app data
- Generate PDF templates with OpenAI or Claude
- PDF generation, document data and API-key security
- PDF template editor or a simple Generate PDF button?