Reportコンポーネントは、タイトルページ、セクション、主要メトリクス、データテーブルを備えた構造化レポートPDFを生成します。ビジネスレポート、四半期レビュー、分析サマリーに最適です。
import "github.com/gpdf-dev/gpdf/template"
doc := template.Report(template.ReportData{
Title: "Quarterly Report",
Subtitle: "Q1 2026 - Financial Summary",
Author: "ACME Corporation",
Date: "April 1, 2026",
Sections: []template.ReportSection{
{
Title: "Executive Summary",
Content: "This report presents the financial performance of ACME Corporation " +
"for the first quarter of 2026. Revenue increased by 15% compared to Q4 2025, " +
"driven primarily by strong growth in the cloud services division.",
Metrics: []template.ReportMetric{
{Label: "Revenue", Value: "$12.5M", ColorHex: 0x2E7D32},
{Label: "Growth", Value: "+15%", ColorHex: 0x2E7D32},
{Label: "Customers", Value: "2,450", ColorHex: 0x1565C0},
{Label: "Margin", Value: "22%", ColorHex: 0x1565C0},
},
},
{
Title: "Revenue Breakdown",
Table: &template.ReportTable{
Header: []string{"Division", "Q1 2026", "Q4 2025", "Change"},
ColumnWidths: []float64{35, 22, 22, 21},
Rows: [][]string{
{"Cloud Services", "$5,200,000", "$4,100,000", "+26.8%"},
{"Enterprise Software", "$3,800,000", "$3,500,000", "+8.6%"},
{"Consulting", "$2,100,000", "$1,900,000", "+10.5%"},
{"Support & Maintenance", "$1,400,000", "$1,350,000", "+3.7%"},
},
},
},
{
Title: "Expense Summary",
Table: &template.ReportTable{
Header: []string{"Category", "Amount", "% of Revenue"},
ColumnWidths: []float64{40, 30, 30},
Rows: [][]string{
{"Personnel", "$5,500,000", "44.0%"},
{"Infrastructure", "$1,800,000", "14.4%"},
{"Marketing", "$1,200,000", "9.6%"},
{"R&D", "$950,000", "7.6%"},
{"General & Admin", "$300,000", "2.4%"},
},
},
},
},
})
data, err := doc.Generate()
┌─ Page 1 (Title) ─────────────────────────────────┐
│ │
│ │
│ Quarterly Report │
│ Q1 2026 - Financial Summary │
│ │
│ ACME Corporation │
│ April 1, 2026 │
│ │
│ │
└───────────────────────────────────────────────────┘
┌─ Page 2 ──────────────────────────────────────────┐
│ │
│ Executive Summary │
│ ──────────────────────────────────────────────── │
│ This report presents the financial performance │
│ of ACME Corporation for Q1 2026... │
│ │
│ ┌──────────┬──────────┬──────────┬──────────┐ │
│ │ Revenue │ Growth │Customers │ Margin │ │
│ │ $12.5M │ +15% │ 2,450 │ 22% │ │
│ └──────────┴──────────┴──────────┴──────────┘ │
│ │
│ Revenue Breakdown │
│ ──────────────────────────────────────────────── │
│ ┌────────────────┬──────────┬──────────┬──────┐ │
│ │ Division │ Q1 2026 │ Q4 2025 │Change│ │
│ ├────────────────┼──────────┼──────────┼──────┤ │
│ │ Cloud Services │$5,200,000│$4,100,000│+26.8%│ │
│ │ Enterprise SW │$3,800,000│$3,500,000│ +8.6%│ │
│ │ Consulting │$2,100,000│$1,900,000│+10.5%│ │
│ │ Support │$1,400,000│$1,350,000│ +3.7%│ │
│ └────────────────┴──────────┴──────────┴──────┘ │
│ │
└───────────────────────────────────────────────────┘