템플릿

보고서

섹션과 지표가 포함된 전문 보고서 PDF 컴포넌트

개요

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%│  │
│  └────────────────┴──────────┴──────────┴──────┘  │
│                                                   │
└───────────────────────────────────────────────────┘

데이터 타입

ReportData

필드타입설명
Titlestring보고서 제목
Subtitlestring보고서 부제목
Authorstring작성자 / 조직명
Datestring보고서 날짜
Sections[]ReportSection보고서 섹션

ReportSection

필드타입설명
Titlestring섹션 제목
Contentstring섹션 본문
Metrics[]ReportMetric카드로 표시되는 핵심 지표
Table*ReportTable선택적 데이터 테이블

ReportMetric

type ReportMetric struct {
    Label    string
    Value    string
    ColorHex uint32    // 값의 Hex 색상 (예: 0x2E7D32)
}

ReportTable

type ReportTable struct {
    Header       []string
    ColumnWidths []float64
    Rows         [][]string
}

커스터마이징

doc := template.Report(reportData,
    template.WithPageSize(document.Letter),
    template.WithFont("Inter", fontData),
)

퍼사드 사용

import "github.com/gpdf-dev/gpdf"

doc := gpdf.NewReport(reportData)