### Forme CLI: Install and Start Dev Server
Source: https://context7.com/danmolitor/forme/llms.txt
Install the Forme CLI globally or locally and start the development server for live preview with hot reloading and an element inspector.
```bash
# Install CLI
npm install -D @formepdf/cli
# Start dev server with live preview
npx forme dev invoice.tsx --data invoice-data.json
# Opens http://localhost:4242 with live reload
```
--------------------------------
### Install Forme dependencies
Source: https://github.com/danmolitor/forme/blob/main/README.md
Install the necessary CLI, React, and core packages to get started with Forme.
```bash
npm install @formepdf/cli @formepdf/react @formepdf/core
```
--------------------------------
### Install Forme Go SDK Packages
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
Use `go get` to install either the API client only or the native templates package, which includes a WASM dependency.
```bash
# API client only (zero dependencies)
go get github.com/formepdf/forme-go
# Native templates (adds wazero dependency)
go get github.com/formepdf/forme-go/templates
```
--------------------------------
### Run Forme with Docker
Source: https://github.com/danmolitor/forme/blob/main/docs/self-hosting.mdx
Example command to start the container with authentication enabled and a sample render request using curl.
```bash
# Start with auth enabled
docker run --rm -p 3000:3000 -e FORME_API_KEY=my-secret formepdf/forme:latest
# Requests require the key
curl -X POST http://localhost:3000/v1/render/invoice \
-H "Authorization: Bearer my-secret" \
-H "Content-Type: application/json" \
-d '{ "data": { "customer": "Acme" } }' \
--output invoice.pdf
```
--------------------------------
### Install Forme Go SDK
Source: https://github.com/danmolitor/forme/blob/main/docs/go-sdk.mdx
Install the API client only for zero dependencies, or include templates for local WASM rendering.
```bash
# API client only (zero dependencies)
go get github.com/formepdf/forme-go
# Local rendering with component DSL (adds wazero)
go get github.com/formepdf/forme-go/templates
```
--------------------------------
### Install @formepdf/sdk
Source: https://github.com/danmolitor/forme/blob/main/packages/sdk/README.md
Install the SDK via npm.
```bash
npm install @formepdf/sdk
```
--------------------------------
### Forme Go SDK Installation
Source: https://github.com/danmolitor/forme/blob/main/docs/go-sdk.mdx
Instructions for installing the Forme Go SDK, with options for API client only or local rendering.
```bash
go get github.com/formepdf/forme-go
# Local rendering with component DSL (adds wazero)
go get github.com/formepdf/forme-go/templates
```
--------------------------------
### Install Forme SDK
Source: https://github.com/danmolitor/forme/blob/main/packages/python-sdk/README.md
Install the package via pip.
```bash
pip install formepdf
```
--------------------------------
### Install dependencies
Source: https://github.com/danmolitor/forme/blob/main/packages/resend/README.md
Install the required packages for Forme and Resend integration.
```bash
npm install @formepdf/resend resend @formepdf/react @formepdf/core
```
--------------------------------
### Start Development Server
Source: https://github.com/danmolitor/forme/blob/main/packages/cli/README.md
Launch the live preview server for a specific template and data file.
```bash
forme dev invoice.tsx --data invoice-data.json
```
--------------------------------
### Run Dev Server
Source: https://github.com/danmolitor/forme/blob/main/CLAUDE.md
Start the development server for live preview. Access it at http://localhost:4242.
```bash
node packages/cli/dist/index.js dev test-preview.tsx
```
--------------------------------
### Install Dependencies
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Run this command in the project root to install all necessary Node.js dependencies.
```bash
npm install
```
--------------------------------
### Install @formepdf/cli
Source: https://github.com/danmolitor/forme/blob/main/packages/cli/README.md
Install the CLI as a development dependency in your project.
```bash
npm install -D @formepdf/cli
```
--------------------------------
### Install @formepdf/next Packages
Source: https://github.com/danmolitor/forme/blob/main/packages/next/README.md
Install the necessary @formepdf packages for Next.js.
```bash
npm install @formepdf/next @formepdf/react @formepdf/core
```
--------------------------------
### Render PDF from JSON
Source: https://github.com/danmolitor/forme/blob/main/docs/rust-sdk.mdx
Quick start example for rendering a PDF document from a JSON string.
```rust
use forme::{render_json, FormeError};
fn main() -> Result<(), FormeError> {
let json = r#"{
"pages": [{ "size": "A4" }],
"children": [{
"kind": "text",
"content": "Hello from Forme!",
"style": { "fontSize": 24, "margin": { "top": 72, "left": 72 } }
}]
}"#;
let pdf_bytes = render_json(json)?;
std::fs::write("hello.pdf", pdf_bytes).unwrap();
Ok(())
}
```
--------------------------------
### Quick start with Forme SDK
Source: https://github.com/danmolitor/forme/blob/main/packages/sdk/README.md
Initialize the client and perform basic PDF rendering and data extraction.
```typescript
import { Forme } from '@formepdf/sdk';
const forme = new Forme('your-api-key');
// Render a template to PDF
const pdf = await forme.render('invoice', {
customerName: 'Acme Corp',
items: [{ name: 'Widget', price: 9.99 }],
});
// pdf is a Uint8Array — write to file, return as response, etc.
await fs.writeFile('invoice.pdf', pdf);
// Extract embedded data from a PDF
const data = await forme.extract(pdf);
// data === { customerName: 'Acme Corp', items: [...] }
```
--------------------------------
### Full Example with Header, Footer, and Table
Source: https://github.com/danmolitor/forme/blob/main/docs/page-breaks.mdx
A comprehensive example demonstrating a repeating header and footer with page numbers, alongside a table as the main content. Ensure necessary components are imported from '@formepdf/react'.
```tsx
import { Document, Page, View, Text, Fixed, Table, Row, Cell } from '@formepdf/react';
export default function Report(data) {
return (
{/* Repeating header */}
My Company
Confidential
{/* Repeating footer with page numbers */}
formepdf.com
Page {'{{pageNumber}}'} of {'{{totalPages}}'
{/* Page content — flows across as many pages as needed */}
Quarterly Report
| Item |
Amount |
{data.items.map((item, i) => (
| {item.name} |
{item.amount} |
))}
);
}
```
--------------------------------
### Run Dev Server
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Start the development server using the CLI, providing a template file to render.
```bash
node packages/cli/dist/index.js dev templates/invoice.tsx
```
--------------------------------
### Run the Forme development server
Source: https://github.com/danmolitor/forme/blob/main/README.md
Start the development server to enable live previews and debug overlays for a specific file and data source.
```bash
npx forme dev invoice.tsx --data sample.json
```
--------------------------------
### Install dependencies
Source: https://github.com/danmolitor/forme/blob/main/packages/hono/README.md
Install the required packages for Hono PDF generation.
```bash
npm install @formepdf/hono @formepdf/react @formepdf/core hono
```
--------------------------------
### Verify npm Packages
Source: https://github.com/danmolitor/forme/blob/main/RELEASE.md
Perform a fresh install test in a temporary directory by creating a new project, installing the published packages, and running a minimal render to ensure functionality.
```bash
# npm — fresh install test
mkdir /tmp/test-forme-080 && cd /tmp/test-forme-080
npm init -y
npm install @formepdf/react @formepdf/core @formepdf/cli
# Run a minimal render
```
--------------------------------
### Install Forme Packages
Source: https://github.com/danmolitor/forme/blob/main/docs/replacing-puppeteer.mdx
Install the necessary Forme packages for React integration and core rendering functionality.
```bash
npm install @formepdf/react @formepdf/core
```
--------------------------------
### Quick Start with Middleware
Source: https://github.com/danmolitor/forme/blob/main/packages/hono/README.md
Initialize the Hono middleware to enable PDF generation via the context.
```typescript
import { Hono } from 'hono';
import { formePdf } from '@formepdf/hono';
const app = new Hono();
app.use(formePdf());
app.get('/invoice/:id', async (c) => {
const invoice = await db.invoices.findById(c.req.param('id'));
return c.pdf('invoice', {
invoiceNumber: invoice.number,
date: invoice.date,
dueDate: invoice.dueDate,
company: { name: 'Acme Corp', initials: 'AC', address: '123 Main St', cityStateZip: 'San Francisco, CA 94105', email: 'billing@acme.com' },
billTo: invoice.customer,
shipTo: invoice.shipping,
items: invoice.lineItems,
taxRate: 0.08,
paymentTerms: 'Net 30',
});
});
export default app;
```
--------------------------------
### Install Forme Crate
Source: https://github.com/danmolitor/forme/blob/main/docs/rust-sdk.mdx
Add the forme-pdf crate to your project dependencies.
```bash
cargo add forme-pdf
```
--------------------------------
### Self-Hosted Docker Container: Quick Start and Health Check
Source: https://context7.com/danmolitor/forme/llms.txt
Run the Forme render engine locally using Docker. This command starts the container and exposes the API on port 3000. Includes a health check endpoint.
```bash
# Quick start
docker run --rm -p 3000:3000 formepdf/forme:latest
# Health check
curl http://localhost:3000/health
# {"status":"ok","version":"0.8.1"}
```
--------------------------------
### Run Forme with Docker
Source: https://github.com/danmolitor/forme/blob/main/docs/self-hosting.mdx
Starts the Forme render engine container on port 3000.
```bash
docker run --rm -p 3000:3000 formepdf/forme:latest
```
--------------------------------
### Verify Go SDK
Source: https://github.com/danmolitor/forme/blob/main/RELEASE.md
Use 'go get' to retrieve the specific version of the Go SDK and verify its presence and version on pkg.go.dev.
```bash
# Go
go get github.com/formepdf/forme-go@v0.8.0
# Check https://pkg.go.dev/github.com/formepdf/forme-go@v0.8.0
```
--------------------------------
### Dump Example Invoice to JSON
Source: https://github.com/danmolitor/forme/blob/main/CLAUDE.md
Generate a JSON representation of an example invoice from the Rust engine.
```bash
cargo run -- --example > invoice.json
```
--------------------------------
### Verify PyPI Package
Source: https://github.com/danmolitor/forme/blob/main/RELEASE.md
Install the specific version of the 'formepdf' package using 'pip' and then print the '__version__' attribute to confirm the correct version is installed.
```bash
# PyPI
pip install formepdf==0.8.0
python -c "import formepdf; print(formepdf.__version__)"
```
--------------------------------
### Create invoice header component
Source: https://github.com/danmolitor/forme/blob/main/docs/tailwind.mdx
A real-world example demonstrating layout, typography, and spacing utilities.
```tsx
Invoice
INV-2024-001
March 18, 2026
Paid
```
--------------------------------
### Install Tailwind CSS Integration
Source: https://github.com/danmolitor/forme/blob/main/README.md
Install the @formepdf/tailwind package to use Tailwind utility classes for styling Forme components. This enables features like spacing, typography, colors, flexbox, grid, borders, opacity, and arbitrary values.
```bash
npm install @formepdf/tailwind
```
--------------------------------
### MCP Server Setup
Source: https://github.com/danmolitor/forme/blob/main/packages/mcp/README.md
Add this configuration to your MCP server to enable the Forme PDF generation capabilities.
```APIDOC
## MCP Server Setup
Add the following configuration to your MCP server's configuration file to integrate with the Forme PDF generation service.
### Configuration
```json
{
"mcpServers": {
"forme": {
"command": "npx",
"args": ["@formepdf/mcp"]
}
}
}
```
After adding this configuration, restart your AI tool for the changes to take effect.
```
--------------------------------
### Forme SDK Usage
Source: https://context7.com/danmolitor/forme/llms.txt
Examples of how to use the Forme SDKs in Node.js, Python, and Go to render PDFs and extract data.
```APIDOC
### Node.js SDK
```typescript
import { Forme } from '@formepdf/sdk';
const forme = new Forme('forme_sk_abc123...');
// Render template to PDF
const pdf = await forme.render('invoice', {
customerName: 'Acme Corp',
items: [{ name: 'Widget', price: 9.99 }],
});
await fs.writeFile('invoice.pdf', pdf);
// Extract embedded data
const data = await forme.extract(pdf);
console.log(data); // { customerName: 'Acme Corp', items: [...] }
```
### Python SDK
```python
from formepdf import Forme
client = Forme("forme_sk_abc123...")
# Render template to PDF
pdf = client.render("invoice", {"customer": "Acme", "total": 100})
with open("invoice.pdf", "wb") as f:
f.write(pdf)
# Extract embedded data
data = client.extract(pdf)
print(data)
```
### Go SDK
```go
package main
import (
"os"
forme "github.com/formepdf/forme-go"
)
func main() {
client := forme.New(os.Getenv("FORME_API_KEY"))
pdf, err := client.Render("invoice", map[string]any{
"customer": "Acme Corp",
"total": 150.00,
})
if err != nil {
panic(err)
}
os.WriteFile("invoice.pdf", pdf, 0644)
}
```
```
--------------------------------
### Start Asynchronous Render Job
Source: https://github.com/danmolitor/forme/blob/main/packages/python-sdk/README.md
Initiate an asynchronous render job and optionally provide a webhook URL for notifications.
```python
job = client.render_async("report", data, webhook_url="https://example.com/hook")
print(job["jobId"])
```
--------------------------------
### Sample Data for Shipping Label
Source: https://github.com/danmolitor/forme/blob/main/docs/template-gallery.mdx
Example JSON object containing the required fields for the ShippingLabel component.
```json
{
"fromName": "Acme Warehouse",
"fromAddress": "500 Commerce Blvd",
"fromCity": "Austin, TX 78701",
"toName": "Jane Smith",
"toAddress": "742 Evergreen Terrace",
"toCity": "Springfield, IL 62704",
"tracking": "1Z999AA10123456784",
"weight": "2.4 lbs",
"dimensions": "12x8x6 in",
"service": "Priority"
}
```
--------------------------------
### Preview PDF in Browser with Live Reload
Source: https://github.com/danmolitor/forme/blob/main/docs/quickstart.mdx
Use the Forme CLI to start a development server that previews your PDF component in the browser. Changes to the component will update the preview instantly.
```bash
npx @formepdf/cli dev invoice.tsx
```
--------------------------------
### Cloudflare Workers Deployment
Source: https://github.com/danmolitor/forme/blob/main/packages/hono/README.md
Example setup for deploying a PDF API on Cloudflare Workers.
```typescript
// src/index.ts
import { Hono } from 'hono';
import { formePdf } from '@formepdf/hono';
const app = new Hono();
app.use(formePdf());
app.get('/invoice', async (c) => {
return c.pdf('invoice', {
invoiceNumber: 'INV-001',
date: 'February 25, 2026',
dueDate: 'March 27, 2026',
company: { name: 'Acme Corp', initials: 'AC', address: '123 Main St', cityStateZip: 'San Francisco, CA 94105', email: 'billing@acme.com' },
billTo: { name: 'Jane Smith', company: 'Smith Co', address: '456 Oak Ave', cityStateZip: 'Portland, OR 97201', email: 'jane@smith.co' },
shipTo: { name: 'Jane Smith', address: '456 Oak Ave', cityStateZip: 'Portland, OR 97201' },
items: [
{ description: 'Consulting', quantity: 10, unitPrice: 150 },
],
taxRate: 0.08,
paymentTerms: 'Net 30',
});
});
export default app;
```
```toml
# wrangler.toml
name = "pdf-api"
compatibility_date = "2024-01-01"
```
```bash
wrangler deploy
```
--------------------------------
### GET /api/invoice/[id]
Source: https://github.com/danmolitor/forme/blob/main/packages/next/README.md
Example of using pdfHandler to create a route handler that generates a PDF invoice from a template.
```APIDOC
## GET /api/invoice/[id]
### Description
Generates a PDF invoice using the built-in 'invoice' template based on data fetched from the database.
### Method
GET
### Endpoint
/api/invoice/[id]
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier for the invoice.
### Request Example
GET /api/invoice/123
### Response
#### Success Response (200)
- **Content-Type** (application/pdf) - The generated PDF document.
```
--------------------------------
### Quick Start: Basic Invoice PDF Route Handler
Source: https://github.com/danmolitor/forme/blob/main/packages/next/README.md
Set up a GET route handler to generate an invoice PDF based on an ID. This handler fetches invoice data and returns it in a format suitable for PDF generation.
```typescript
// app/api/invoice/[id]/route.ts
import { pdfHandler } from '@formepdf/next';
export const GET = pdfHandler('invoice', async (req, { params }) => {
const invoice = await db.invoices.findById(params.id);
return {
invoiceNumber: invoice.number,
date: invoice.date,
dueDate: invoice.dueDate,
company: { name: 'Acme Corp', initials: 'AC', address: '123 Main St', cityStateZip: 'San Francisco, CA 94105', email: 'billing@acme.com' },
billTo: invoice.customer,
shipTo: invoice.shipping,
items: invoice.lineItems,
taxRate: 0.08,
paymentTerms: 'Net 30',
};
});
```
--------------------------------
### Initialize and Render PDF
Source: https://github.com/danmolitor/forme/blob/main/packages/python-sdk/README.md
Initialize the client with an API key and render a template to PDF bytes.
```python
from formepdf import Forme
client = Forme("forme_sk_...")
# Render a template to PDF bytes
pdf = client.render("invoice", {"customer": "Acme", "total": 100})
with open("invoice.pdf", "wb") as f:
f.write(pdf)
```
--------------------------------
### Client Initialization
Source: https://github.com/danmolitor/forme/blob/main/packages/python-sdk/README.md
Initialize the Forme client with your API key.
```python
from formepdf import Forme
client = Forme("forme_sk_...")
```
--------------------------------
### Invoice Data JSON Example
Source: https://context7.com/danmolitor/forme/llms.txt
Example JSON structure for providing data to an invoice template when using the Forme CLI or SDKs.
```json
// invoice-data.json
{
"title": "Invoice #2024-001",
"customerName": "Acme Corp",
"items": [
{ "name": "Widget Pro", "price": 49.00 },
{ "name": "Gadget Plus", "price": 129.00 }
],
"total": 178.00
}
```
--------------------------------
### Quick Start: Render Template with Hosted API
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
Initialize the client with your API key and use it to render a template to PDF by providing the template slug and data. You can also extract embedded data from a PDF.
```go
package main
import (
"os"
forme "github.com/formepdf/forme-go"
)
func main() {
client := forme.New(os.Getenv("FORME_API_KEY"))
// Render a template to PDF
pdf, err := client.Render("invoice", map[string]any{
"customer": "Acme Corp",
"total": 150.00,
})
if err != nil {
panic(err)
}
os.WriteFile("invoice.pdf", pdf, 0644)
// Extract embedded data from a PDF
data, err := client.Extract(pdf)
if err != nil {
panic(err)
}
// data == map[string]any{"customer": "Acme Corp", "total": 150.00}
}
```
--------------------------------
### Connect SDK to Self-Hosted Instance
Source: https://context7.com/danmolitor/forme/llms.txt
Initialize the Forme client by specifying the base URL of your self-hosted instance.
```typescript
// Point SDK at self-hosted instance
import { Forme } from '@formepdf/sdk';
const client = new Forme('your-key', {
baseUrl: 'http://localhost:3000'
});
const pdf = await client.render('invoice', { customer: 'Acme' });
```
--------------------------------
### Quick Start: Native Templates for Local Rendering
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
Define a document structure using the component DSL and render it to PDF locally. This requires WASM and can be built with `-tags forme_wasm`. The document can also be serialized to JSON.
```go
package main
import (
"os"
t "github.com/formepdf/forme-go/templates"
)
func main() {
doc := t.Document(
t.Page(
t.View(
t.Text("Invoice", t.Style{FontSize: 24, FontWeight: "bold"}),
t.Text("Acme Corp", t.Style{FontSize: 14, Color: "#666"}),
).Style(t.Style{FlexDirection: "column", Gap: 8}),
t.Table(
t.Row(t.Cell(t.Text("Item")), t.Cell(t.Text("Price"))).Header(true),
t.Row(t.Cell(t.Text("Widget")), t.Cell(t.Text("$50.00"))),
t.Row(t.Cell(t.Text("Gadget")), t.Cell(t.Text("$100.00"))),
).Columns([]t.Column{{Width: "1fr"}, {Width: 100.0}}),
),
).Title("Invoice #001")
// Serialize to JSON (no WASM needed)
json, _ := doc.ToJSON()
// Render to PDF (requires WASM — build with -tags forme_wasm)
pdf, err := doc.Render()
if err != nil {
panic(err)
}
os.WriteFile("invoice.pdf", pdf, 0644)
_ = json
}
```
--------------------------------
### Publish Go SDK
Source: https://github.com/danmolitor/forme/blob/main/RELEASE.md
After running tests, commit and push changes to the Go SDK repository. Tag the release with 'git tag' and push the tag to create a new version for pkg.go.dev.
```bash
cd packages/go-sdk
# Verify tests pass
go test ./...
# Push to the Go SDK repo
git add .
git commit -m "Release v0.8.0"
git push origin main
# Tag the release (Go modules use the tag as the version)
git tag v0.8.0
git push origin v0.8.0
# pkg.go.dev will index it automatically within ~30 minutes
# Verify at: https://pkg.go.dev/github.com/formepdf/forme-go
```
--------------------------------
### PageBreak Component
Source: https://github.com/danmolitor/forme/blob/main/docs/components.mdx
Forces content after this element to start on a new page.
```APIDOC
## PageBreak Component
### Props
None.
```
--------------------------------
### PDF/A Conformance Levels
Source: https://github.com/danmolitor/forme/blob/main/docs/archival.mdx
Examples of setting different PDF/A conformance levels.
```tsx
{/* Most common -- visual preservation */}
...
{/* Tagged structure required (forces tagging, same as pdfUa) */}
...
```
--------------------------------
### Configure Forme SDKs
Source: https://github.com/danmolitor/forme/blob/main/docs/self-hosting.mdx
Initialize the Forme client with a custom base URL pointing to your self-hosted instance.
```javascript
import { FormeClient } from "@formepdf/sdk";
const client = new FormeClient({
baseUrl: "http://localhost:3000",
apiKey: "your-key",
});
```
```python
import formepdf
client = formepdf.Client(base_url="http://localhost:3000", api_key="your-key")
```
```go
import forme "github.com/formepdf/forme-go"
client := forme.New("your-key", forme.WithBaseURL("http://localhost:3000"))
```
--------------------------------
### Test React Package
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Navigate to the React package directory and run its test suite.
```bash
cd packages/react && npm test
```
--------------------------------
### Initialize Application: WebSocket or VS Code
Source: https://github.com/danmolitor/forme/blob/main/packages/renderer/src/preview/index.html
Initializes the application by either connecting to a WebSocket for standalone use or signaling readiness to VS Code if running within that environment. Calls `connectWs` for WebSocket or posts a 'ready' message to VS Code. Also performs an initial `reload` and `zoomToFit`.
```javascript
if (!isVSCode) {
connectWs();
reload().then(() => {
setTimeout(zoomToFit, 100);
}).catch(() => {});
}
```
--------------------------------
### GET /health
Source: https://github.com/danmolitor/forme/blob/main/docs/self-hosting.mdx
Provides a health check for the Forme render engine, returning its status and version.
```APIDOC
## GET /health
### Description
Health check endpoint for the Forme render engine.
### Method
GET
### Endpoint
/health
### Response
#### Success Response (200)
- **status** (string) - The health status of the service (e.g., "ok").
- **version** (string) - The version of the Forme render engine.
### Response Example
```json
{
"status": "ok",
"version": "0.8.1"
}
```
```
--------------------------------
### Building WASM for Local Rendering
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
Instructions for building the WASM binary for local rendering with Forme.
```APIDOC
## Building WASM for Local Rendering
```bash
cd packages/go-sdk/templates
bash build_wasm.sh
go test -tags forme_wasm ./...
```
The WASM binary is `.gitignore`d — build it locally or download from releases.
```
--------------------------------
### Render to buffer in react-pdf
Source: https://github.com/danmolitor/forme/blob/main/docs/migrating-from-react-pdf.mdx
Use renderToBuffer to get PDF bytes as a Node.js Buffer in react-pdf.
```tsx
import { renderToBuffer } from '@react-pdf/renderer';
const buffer = await renderToBuffer();
```
--------------------------------
### PieChart Example
Source: https://github.com/danmolitor/forme/blob/main/docs/components.mdx
Generates a pie or donut chart with an optional legend. Ideal for showing proportions of a whole.
```tsx
```
--------------------------------
### Build Engine (Rust)
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Navigate to the engine directory and run tests to build and verify the Rust engine.
```bash
cd engine && cargo test
```
--------------------------------
### Forme Client Constructor
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
How to initialize the Forme API client.
```APIDOC
## Constructor
### Description
Initializes a new Forme API client instance.
### Signature
`client := forme.New(apiKey string, opts ...forme.Option)`
### Options
- **forme.WithBaseURL(url)** - Custom API base URL (default: https://api.formepdf.com)
- **forme.WithHTTPClient(c)** - Custom *http.Client
```
--------------------------------
### Font Fallback Chain Example
Source: https://github.com/danmolitor/forme/blob/main/CLAUDE.md
Specify fallback font families separated by commas. The system tries each in order.
```css
fontFamily: "Inter, Helvetica"
```
--------------------------------
### Build CLI Package
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Navigate to the CLI package directory and run the build script to compile the Command Line Interface.
```bash
cd packages/cli && npm run build
```
--------------------------------
### Execute Project Build Order
Source: https://github.com/danmolitor/forme/blob/main/RELEASE.md
Sequential commands to build project components, respecting dependency chains from the engine up to integration packages and SDKs.
```bash
# 1. Engine (Rust) — only if engine/ changed
cd engine
cargo fmt
cargo clippy -- -W clippy::all
cargo test
# 2. React (JSX components, serialize, types)
cd packages/react
npm run build
npm test
# 3. Core (WASM bridge — compiles engine to WebAssembly)
cd packages/core
npm run build # runs wasm-pack + tsc
# 4. Renderer (shared render pipeline — depends on react + core)
cd packages/renderer
npm run build
npm test
# 5. CLI (dev server + build command — depends on renderer)
cd packages/cli
npm run build
# 6. VS Code extension (depends on renderer)
cd packages/vscode
npm run build # esbuild bundle + copies WASM + preview HTML
# 7. Integration and utility packages (depend on react + core)
cd packages/hono && npm run build
cd packages/next && npm run build
cd packages/mcp && npm run build
cd packages/resend && npm run build
# 8. Packages with no build step (verify they resolve correctly)
cd packages/sdk && npm run build # TypeScript hosted API client
cd packages/tailwind && npm run build # tw() function, Tailwind v3
cd packages/templates && npm run build # shared templates + Zod schemas
# 9. Python SDK — rebuild WASM (only if engine/ changed)
cd packages/python-sdk
bash build_wasm.sh # builds wasm32-wasip1 target, copies to formepdf/forme.wasm
# 10. Go SDK — rebuild WASM (only if engine/ changed)
# The Go SDK is a separate git repo at packages/go-sdk/
# It uses //go:embed for the WASM binary (gitignored, must be present locally)
cd packages/go-sdk
bash templates/build_wasm.sh # or copy from engine target:
# cp ../../engine/target/wasm32-wasip1/release/forme.wasm templates/forme.wasm
```
--------------------------------
### Sample Receipt Data Structure
Source: https://github.com/danmolitor/forme/blob/main/docs/template-gallery.mdx
Example JSON object representing the data structure required by the Receipt component.
```json
{
"storeName": "Sunrise Cafe",
"date": "2024-01-15",
"taxRate": 0.085,
"items": [
{ "name": "Cappuccino", "price": 5.50, "quantity": 2 },
{ "name": "Croissant", "price": 3.75, "quantity": 1 },
{ "name": "Orange Juice", "price": 4.25, "quantity": 1 }
]
}
```
--------------------------------
### Build PDF
Source: https://github.com/danmolitor/forme/blob/main/packages/cli/README.md
Render a template to a PDF file using the specified data.
```bash
forme build invoice.tsx --data invoice-data.json -o invoice.pdf
```
--------------------------------
### BarChart Example
Source: https://github.com/danmolitor/forme/blob/main/docs/components.mdx
Renders a simple bar chart with specified data, dimensions, and styling. Use for displaying categorical data.
```tsx
```
--------------------------------
### Forme API Client Constructor
Source: https://github.com/danmolitor/forme/blob/main/packages/go-sdk/README.md
Instantiate the Forme API client with your API key. Optional arguments allow for a custom base URL or HTTP client.
```go
client := forme.New(apiKey string, opts ...forme.Option)
| Option | Description |
|--------|-------------|
| `forme.WithBaseURL(url)` | Custom API base URL (default: `https://api.formepdf.com`) |
| `forme.WithHTTPClient(c)` | Custom `*http.Client` |
```
--------------------------------
### Watermark Example
Source: https://github.com/danmolitor/forme/blob/main/docs/components.mdx
Adds a rotated text watermark behind page content, useful for indicating document status like 'DRAFT'.
```tsx
Document content here...
```
--------------------------------
### Build WASM Package
Source: https://github.com/danmolitor/forme/blob/main/CONTRIBUTING.md
Navigate to the core package directory and run the build script to compile the WebAssembly module.
```bash
cd packages/core && npm run build
```
--------------------------------
### LineChart Example
Source: https://github.com/danmolitor/forme/blob/main/docs/components.mdx
Creates a multi-series line chart with optional data points and grid lines. Suitable for time-series or trend data.
```tsx
```
--------------------------------
### CLI Dev Server
Source: https://context7.com/danmolitor/forme/llms.txt
Utilize the Forme CLI for local development, including live preview, hot reloading, and building PDF files.
```APIDOC
### Installation
```bash
npm install -D @formepdf/cli
```
### Start Dev Server
```bash
npx forme dev invoice.tsx --data invoice-data.json
```
This command starts a local development server with live preview at `http://localhost:4242`.
### Build to PDF
```bash
npx forme build invoice.tsx --data invoice-data.json -o invoice.pdf
```
Compiles a template and data into a PDF file.
### Compile Template
```bash
npx forme build --template invoice.tsx
```
Compiles a template into a JSON format suitable for self-hosting.
```