Documentation

Templates & Test Data

How to manage and add showcase templates.

To facilitate development, testing, and the showcase gallery, PaperCast includes a robust set of predefined JSON document templates.

src/store/test.data.ts

This file contains large, complex DocumentSchema objects that demonstrate the capabilities of the engine, mostly used for fallback testing.

src/schema/*.template.json

Recently, we have transitioned to storing templates as raw JSON files in the src/schema/ directory. This makes them easily readable by both human developers and AI agents over MCP.

Included JSON Templates:

  1. src/schema/invoice.template.json: Demonstrates tables, auto-pagination for long item lists, and data-binding for customer information.
  2. src/schema/report.template.json: Highlights complex multi-column layouts and styled headers.

Adding a New Template

To add a new template for the showcase or for testing a specific bug:

  1. Open src/store/test.data.ts.
  2. Export a new constant typed as DocumentSchema.
  3. (Optional) Add your template to a central array if the UI needs to map over available templates.
export const MY_NEW_TEMPLATE: DocumentSchema = {
  version: 1,
  meta: { pageSize: "A4", orientation: "portrait" },
  theme: { defaults: { base: { fontFamily: "Inter" } } },
  document: {
    headers: {},
    footers: {},
    body: {
      id: "root-column",
      type: "column",
      children: [
        { id: "text-1", type: "text", props: { literal: "Hello World" } },
      ],
    },
  },
};
Data Injection

When designing a template, make sure to utilize the data block. This allows you to showcase how {{ variable }} interpolation works beautifully for dynamic document generation!