Build Dynamic Reports
Create data-driven reports with tables, charts, and dynamic content.
What You'll Build
A multi-section report template with a cover page, summary statistics, data tables, and a footer. This pattern works for financial reports, analytics summaries, HR reports, and more.
Report Structure
Most reports follow a common layout:
- Header — Company branding + report title
- Metadata — Report date, period, department
- Summary Section — Key metrics at a glance
- Data Table — Detailed breakdown
- Footer — Notes, disclaimers, page info
Step 1: Set Up the Page
- Create a new template named "Monthly Report"
- Use A4 Portrait — standard for business reports
- Set margins to 40px for clean spacing
- Use a light background (#fafafa) for a softer look
Step 2: Build the Header
- Add your company logo (Image element) in the top-left
- Add a Field element with key
report_title— position it prominently at 24–28px - Below, add fields for
report_periodandgenerated_date - Add a line to separate the header from the body
Step 3: Add Summary Metrics
Create a row of key metric cards using grouped elements:
- For each metric, create a text label and a field element:
- Label: "Total Revenue" → Field key:
total_revenue - Label: "Orders" → Field key:
total_orders - Label: "Growth" → Field key:
growth_percentage
- Label: "Total Revenue" → Field key:
- Style the field values larger (20–24px) and bold to make them stand out
- Arrange them in a horizontal row across the page
Use background rectangles behind each metric to create a "card" look. A light border and subtle shadow color makes them pop.
Step 4: Add the Data Table
- Add a Table element below the summary section
- Bind it to a data key, e.g.,
monthly_data - Configure columns for your report type. For a sales report:
- Product — field key:
product - Units Sold — field key:
units - Revenue — field key:
revenue - % of Total — field key:
percentage
- Product — field key:
- Style the header row with your brand's accent color
Step 5: Add a Footer
- Add a line near the page bottom as a separator
- Add a text element: "Confidential — Internal Use Only"
- Add a field for
report_notesfor dynamic per-report notes
Generate via API
TypeScript
const pdf = await client.generate({
templateId: "tmpl_monthly_report",
data: {
report_title: "Monthly Sales Report",
report_period: "January 2026",
generated_date: "February 1, 2026",
total_revenue: "$142,500",
total_orders: "1,247",
growth_percentage: "+12.3%",
monthly_data: [
{ product: "Enterprise Plan", units: "45", revenue: "$67,500", percentage: "47%" },
{ product: "Pro Plan", units: "312", revenue: "$46,800", percentage: "33%" },
{ product: "Starter Plan", units: "890", revenue: "$28,200", percentage: "20%" },
],
report_notes: "Q1 target is on track. Enterprise sales exceeded forecast by 15%.",
},
});Automating Report Generation
Combine the API with a scheduler (cron, Vercel Cron, AWS EventBridge) to generate reports automatically:
TypeScript
// Example: Generate a report at the start of each month
// Run this as a scheduled job
async function generateMonthlyReport() {
const data = await fetchSalesData(lastMonth());
const pdf = await client.generate({
templateId: "tmpl_monthly_report",
data: {
report_title: "Monthly Sales Report",
report_period: formatMonth(lastMonth()),
generated_date: formatDate(new Date()),
total_revenue: formatCurrency(data.totalRevenue),
total_orders: data.totalOrders.toLocaleString(),
growth_percentage: formatPercentage(data.growth),
monthly_data: data.products.map(p => ({
product: p.name,
units: p.units.toString(),
revenue: formatCurrency(p.revenue),
percentage: formatPercentage(p.share),
})),
},
});
// Email to stakeholders, upload to shared drive, etc.
await emailReport(pdf, ["ceo@company.com", "sales@company.com"]);
}This pattern works for any recurring report — financial statements, HR summaries, inventory reports, analytics dashboards, and more.