> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pdfdyno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Report

> A multi-page data report with headers, footers, pagination, and data tables.

<Frame>
  <img src="https://mintcdn.com/pdf-dyno/pat72jpBFeHUuLAU/images/templates/report.png?fit=max&auto=format&n=pat72jpBFeHUuLAU&q=85&s=1fb09eb4528694fb88b86c39392662fa" alt="Data Report Preview" width="550" height="782" data-path="images/templates/report.png" />
</Frame>

This template is perfect for monthly analytics reports, HR summaries, or financial statements. It demonstrates how to implement headers, footers, and automatic pagination (Page X of Y).

<CodeGroup>
  ```typst template.typ theme={null}

  // CHANGE BRAND COLOR HERE
  #let brand-color = rgb("#334155")

  // Page Setup with Header and Footer
  #set page(
    paper: "a4",
    margin: (top: 3cm, bottom: 2.5cm, left: 2cm, right: 2cm),
    
    // Header: Logo and Report Title
    header: [
      #grid(
        columns: (1fr, auto),
        [#text(weight: "bold", fill: brand-color)[PDFDyno Analytics]],
        [#text(fill: luma(100))[#data.report_title]]
      )
      #line(length: 100%, stroke: 0.5pt + luma(200))
    ],
    
    // Footer: Pagination
    footer: [
      #line(length: 100%, stroke: 0.5pt + luma(200))
      #align(center)[
        #text(size: 9pt, fill: luma(150))[
          // Automatic page numbers via Typst context
          #context [
            Page #counter(page).display() of #counter(page).final().at(0)
          ]
        ]
      ]
    ]
  )

  #set text(font: "Helvetica", size: 10pt)

  // Title Section
  #align(center)[
    #text(size: 24pt, weight: "bold")[#data.report_title] \
    #v(5pt)
    #text(size: 12pt, fill: luma(100))[Generated on: #data.generated_date]
  ]

  #v(1.5cm)

  // Executive Summary
  #block(fill: rgb("#f3f4f6"), inset: 15pt, radius: 5pt, width: 100%)[
    *Executive Summary* \
    #data.summary
  ]

  #v(1cm)

  // Data Table
  *Performance Metrics:*
  #v(5pt)

  #table(
    columns: (1fr, auto, auto, auto),
    inset: 10pt,
    fill: (x, y) => if y == 0 { brand-color } else if calc.even(y) { rgb("#f9fafb") } else { white },
    stroke: 0.5pt + luma(200),
    
    // Table Header (white text on brand color)
    [#text(fill: white)[*Metric*]],
    [#text(fill: white)[*Current*]],
    [#text(fill: white)[*Previous*]],
    [#text(fill: white)[*Change*]],
    
    // Generate rows
    ..data.metrics.map(row => (
      row.name,
      row.current,
      row.previous,
      row.change
    )).flatten()
  )

  #v(1fr)
  // This forces the following text to the end of the page, or onto the next page
  ```

  ```json data.json theme={null}
  {
    "report_title": "Monthly API Usage Report",
    "generated_date": "August 5, 2026",
    "summary": "This month saw a 15% increase in API requests compared to the previous period. Error rates dropped to 0.01% due to the recent backend optimization.",
    "metrics": [
      {
        "name": "Total API Requests",
        "current": "1,250,000",
        "previous": "1,085,000",
        "change": "+15.2%"
      },
      {
        "name": "Average Latency",
        "current": "42ms",
        "previous": "48ms",
        "change": "-12.5%"
      },
      {
        "name": "Error Rate (5xx)",
        "current": "0.01%",
        "previous": "0.04%",
        "change": "-75.0%"
      },
      {
        "name": "Active Users",
        "current": "4,200",
        "previous": "3,950",
        "change": "+6.3%"
      }
    ]
  }
  ```

  ```bash cURL (Try It) theme={null}
  # 1. Save the Typst code from the tab above as 'template.typ'
  # 2. Save the JSON data from the tab above as 'data.json'

  # 3. Combine them and call the API (requires jq)
  jq -n \
    --arg t "$(cat template.typ)" \
    --argjson d "$(<data.json)" \
    '{ "data": $d, "template": $t }' > request.json

  curl -X POST https://api.pdfdyno.com/v1/pdf/generate \
    -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d @request.json \
    --output report.pdf
  ```
</CodeGroup>
