---
source: https://carbone.io/examples/s-annual-report-html/
title: "Report Generation Software: HTML to PDF Reports | Carbone"
description: "Automate report generation from an HTML template and JSON with Carbone: loops for cards and tables, colors from data, ECharts charts, Chromium rendering."
generated_at: "2026-11-17"
---

# HTML annual report

Key figures and quarterly results, with charts drawn by ECharts

[![HTML annual report: PDF generated from an HTML template and JSON data](/examples/s-annual-report-html/thumb-result.webp)](/examples/s-annual-report-html/result.pdf "Download the generated document")

[Download template](/examples/s-annual-report-html/template.md)

[Sample data](/examples/s-annual-report-html/data.json)

[Download the generated PDF](/examples/s-annual-report-html/result.pdf)

- **Template:** HTML
- **Export as:** PDF, HTML, PNG, WebP [+7 more](/documentation/developer/http-api/generate-reports.md#output-file-type)
- **Carbone:** 5.0+

Features

-   [HTML](/documentation/design/advanced-features/html.md)
-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Chart](/documentation/design/advanced-features/charts.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Color](/documentation/design/advanced-features/colors.md)

## Generate PDF reports from your SaaS data

Finance, investor relations and SaaS analytics teams publish reports that mix key figures, tables and charts, and they often design them for the web first. Your application sends the figures to the Carbone API as JSON, and an HTML template styled with CSS becomes a multi-page PDF report, with charts drawn by ECharts and rendered by Chromium. Here, the annual report of a company presents its key figures, quarterly results, revenue breakdown and outlook, with cards, tables and charts filled from JSON data.

In this example, you will:

-   Lay out an A4 report in HTML and CSS
-   Repeat cards and table rows in loops
-   Style the elements and insert charts from the data
-   Convert the HTML template to PDF

## How to build a multi-page PDF report in HTML

Follow these steps to generate an annual report from an HTML template with Carbone:

### 1\. Set Up the Pages, PDF Options and Footer

In a code editor, create an HTML document with your CSS in a `<style>` block. Place each page in a `<div>` that starts with `page-break-before: always`. Then set the [PDF options](/documentation/design/template-formats/html.md#pdf-conversion-options) and the [footer](/documentation/design/template-formats/html.md#headers-footers) with Carbone elements:

```html
<carbone-pdf-options paper-size="A4" print-background="true" display-header-footer="true" margin-top="0" margin-bottom="0.35" margin-left="0" margin-right="0"/>

<carbone-pdf-footer>
  <div>{d.company.name} | Annual Report {d.report.fiscalYear}</div>
  <div>Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>
</carbone-pdf-footer>
```

### 2\. Repeat the Cards and Table Rows

Display the data with [Carbone tags](/documentation/design/substitutions/the-basics.md), such as `{d.company.name}` or `{d.report.fiscalYear}`, and repeat the cards and table rows in [loops](/documentation/design/template-formats/html.md#loops). Everything between the first tag `[i]` and the tag `[i+1]` repeats for each item. Place `[i+1]` in a hidden element right after the repeated block:

```html
<tr>
  <td>{d.financialPerformance.quarterlyRows[i].quarter}</td>
  <td>{d.financialPerformance.quarterlyRows[i].revenue}</td>
</tr>
<tr style="display:none;"><td>{d.financialPerformance.quarterlyRows[i+1].quarter}</td></tr>
```

The cover figures, key performance cards, milestones, segments, regions, guidance, risks and board members use the same pattern.

### 3\. Style the Elements from the Data

[Insert CSS values](/documentation/design/template-formats/html.md#conditions-inject-css-values-example) from the data in the `style` attributes, for example the background of a row or the color of a segment:

```html
<td style="background:{d.revenueBreakdown.segments[i].rowBg};">{d.revenueBreakdown.segments[i].name}</td>
```

To display a **Fastest Growing** badge on some regions only, surround it with [showBegin and showEnd](/documentation/design/template-formats/html.md#conditions-showbegin-showend-example):

```html
{d.revenueBreakdown.geographies[i].fastestGrowing:ifEQ(true):showBegin}<span>Fastest Growing</span>{d.revenueBreakdown.geographies[i].fastestGrowing:showEnd}
```

### 4\. Insert the Charts

The data contains an [ECharts](/documentation/design/advanced-features/charts.md#html-echart-example) configuration for each chart: monthly recurring revenue, revenue by segment and net revenue retention. Insert each chart in an `<img>` tag with the `:chart` formatter:

```html
<img src="{d.financialPerformance.mrrChart:chart}" style="width:100%;" alt="Monthly Recurring Revenue">
```

### 5\. Convert the HTML to PDF

When you generate the report, select **Chromium** as the **Document Converter**, or set `"converter": "C"` in the [API request](/documentation/design/template-formats/html.md#convert-html-to-pdf). The PDF then matches the layout displayed in the browser.

Save the HTML template, connect it to your JSON data, and let Carbone generate your annual report automatically.

## Related Examples

Check out these similar templates to learn more:

- [HTML invoice to PDF](/examples/html-report/index.md): HTML template to PDF.
- [Quarterly financial dashboard](/examples/s-financial-dashboard/index.md): XLSX template to XLSX.
- [Monthly treasury FX report](/examples/financial-report/index.md): DOCX template to PDF.

## Related topics

- [Inventory by product and size](/examples/shoes/index.md)
- [eNPS survey report by department](/examples/bargraph/index.md)
- [Sales pipeline review slide](/examples/kanban/index.md)
- [Project status report](/examples/mission-report/index.md)
- [Vehicle condition report](/examples/check-out/index.md)
- [Maintenance work order](/examples/maintenance-work-order/index.md)
