# go-pdf/fpdf architecture

> Architecture diagram of the GitHub repository go-pdf/fpdf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/go-pdf/fpdf
- Repository: https://github.com/go-pdf/fpdf

## Overview

GoFPDF is an archived Go library for generating PDF documents. The principal workflow is a Go application configuring a document, adding pages and content, then writing PDF output. Its source tree also shows support for fonts, images, SVG, templates, layout helpers, attachments, layers, and optional integrations for barcodes and importing PDFs. The README only identifies the product and its archived status; it does not document the internal call flow, so unverified relationships are shown as dashed with no evidence path.

Main entry points: [`fpdf.go`](https://github.com/go-pdf/fpdf/blob/main/fpdf.go) (PDF document API), [`font.go`](https://github.com/go-pdf/fpdf/blob/main/font.go) (Font handling), [`contrib/barcode/barcode.go`](https://github.com/go-pdf/fpdf/blob/main/contrib/barcode/barcode.go) (Barcode integration), [`contrib/gofpdi/gofpdi.go`](https://github.com/go-pdf/fpdf/blob/main/contrib/gofpdi/gofpdi.go) (PDF page import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["PDF generation"]
  node_fpdf["PDF document API<br/>[fpdf.go]"]
  node_definitions["Document defaults<br/>[def.go]"]
  node_writer["PDF output writer<br/>[wbuf.go]"]
  node_utility["PDF utilities<br/>[util.go]"]
end

subgraph group_content["Document content"]
  node_text["Text and Unicode<br/>[fpdftrans.go]"]
  node_grid["Grid layout<br/>[grid.go]"]
  node_html["Basic HTML<br/>[htmlbasic.go]"]
  node_lists["Text lists<br/>[list.go]"]
  node_svg["SVG drawing<br/>[svgbasic.go]"]
  node_templates["Templates<br/>[template_impl.go]"]
  node_attachments["Embedded files<br/>[attachments.go]"]
  node_layers["PDF layers<br/>[layer.go]"]
end

subgraph group_assets["Fonts and assets"]
  node_fonts["Font handling<br/>[font.go]"]
  node_ttf["TrueType parsing<br/>[ttfparser.go]"]
  node_fontdata["Bundled font data<br/>[files.go]"]
  node_images["Image handling<br/>[png.go]"]
end

subgraph group_integrations["Optional integrations"]
  node_barcode["Barcode integration<br/>[barcode.go]"]
  node_pdfimport["PDF page import<br/>[gofpdi.go]"]
  node_httpimages["HTTP images<br/>[httpimg.go]"]
  node_tiff["TIFF images<br/>[tiff.go]"]
end

node_app(("Go application"))
node_pdf["Generated PDF"]

node_app -.->|"uses"| node_fpdf
node_fpdf -.->|"writes"| node_pdf
node_fpdf -.->|"uses defaults"| node_definitions
node_fpdf -.->|"serializes through"| node_writer
node_fpdf -.->|"uses"| node_utility
node_fpdf -.->|"supports"| node_text
node_fpdf -.->|"supports"| node_grid
node_fpdf -.->|"supports"| node_html
node_fpdf -.->|"supports"| node_svg
node_fpdf -.->|"supports"| node_templates
node_fpdf -.->|"supports"| node_attachments
node_fpdf -.->|"supports"| node_layers
node_fpdf -.->|"supports"| node_fonts
node_fonts -.->|"parses fonts"| node_ttf
node_fonts -.->|"uses data"| node_fontdata
node_fpdf -.->|"supports"| node_images
node_barcode -->|"registers images"| node_fpdf
node_pdfimport -->|"imports templates"| node_fpdf
node_httpimages -->|"registers images"| node_fpdf
node_tiff -->|"registers images"| node_fpdf

click node_fpdf "https://github.com/go-pdf/fpdf/blob/main/fpdf.go"
click node_definitions "https://github.com/go-pdf/fpdf/blob/main/def.go"
click node_writer "https://github.com/go-pdf/fpdf/blob/main/wbuf.go"
click node_utility "https://github.com/go-pdf/fpdf/blob/main/util.go"
click node_text "https://github.com/go-pdf/fpdf/blob/main/fpdftrans.go"
click node_grid "https://github.com/go-pdf/fpdf/blob/main/grid.go"
click node_html "https://github.com/go-pdf/fpdf/blob/main/htmlbasic.go"
click node_lists "https://github.com/go-pdf/fpdf/blob/main/list/list.go"
click node_svg "https://github.com/go-pdf/fpdf/blob/main/svgbasic.go"
click node_templates "https://github.com/go-pdf/fpdf/blob/main/template_impl.go"
click node_attachments "https://github.com/go-pdf/fpdf/blob/main/attachments.go"
click node_layers "https://github.com/go-pdf/fpdf/blob/main/layer.go"
click node_fonts "https://github.com/go-pdf/fpdf/blob/main/font.go"
click node_ttf "https://github.com/go-pdf/fpdf/blob/main/ttfparser.go"
click node_fontdata "https://github.com/go-pdf/fpdf/blob/main/internal/files/files.go"
click node_images "https://github.com/go-pdf/fpdf/blob/main/png.go"
click node_barcode "https://github.com/go-pdf/fpdf/blob/main/contrib/barcode/barcode.go"
click node_pdfimport "https://github.com/go-pdf/fpdf/blob/main/contrib/gofpdi/gofpdi.go"
click node_httpimages "https://github.com/go-pdf/fpdf/blob/main/contrib/httpimg/httpimg.go"
click node_tiff "https://github.com/go-pdf/fpdf/blob/main/contrib/tiff/tiff.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fpdf,node_definitions,node_writer,node_utility toneBlue
class node_text,node_grid,node_html,node_lists,node_svg,node_templates,node_attachments,node_layers toneAmber
class node_fonts,node_ttf,node_fontdata,node_images toneMint
class node_barcode,node_pdfimport,node_httpimages,node_tiff toneRose
class node_app,node_pdf toneIndigo
```

## Components

### PDF generation

- [PDF document API](https://github.com/go-pdf/fpdf/blob/main/fpdf.go): `fpdf.go`
- [Document defaults](https://github.com/go-pdf/fpdf/blob/main/def.go): `def.go`
- [PDF output writer](https://github.com/go-pdf/fpdf/blob/main/wbuf.go): `wbuf.go`
- [PDF utilities](https://github.com/go-pdf/fpdf/blob/main/util.go): `util.go`

### Document content

- [Text and Unicode](https://github.com/go-pdf/fpdf/blob/main/fpdftrans.go): `fpdftrans.go`
- [Grid layout](https://github.com/go-pdf/fpdf/blob/main/grid.go): `grid.go`
- [Basic HTML](https://github.com/go-pdf/fpdf/blob/main/htmlbasic.go): `htmlbasic.go`
- [Text lists](https://github.com/go-pdf/fpdf/blob/main/list/list.go): `list/list.go`
- [SVG drawing](https://github.com/go-pdf/fpdf/blob/main/svgbasic.go): `svgbasic.go`
- [Templates](https://github.com/go-pdf/fpdf/blob/main/template_impl.go): `template_impl.go`
- [Embedded files](https://github.com/go-pdf/fpdf/blob/main/attachments.go): `attachments.go`
- [PDF layers](https://github.com/go-pdf/fpdf/blob/main/layer.go): `layer.go`

### Fonts and assets

- [Font handling](https://github.com/go-pdf/fpdf/blob/main/font.go): `font.go`
- [TrueType parsing](https://github.com/go-pdf/fpdf/blob/main/ttfparser.go): `ttfparser.go`
- [Bundled font data](https://github.com/go-pdf/fpdf/blob/main/internal/files/files.go): `internal/files/files.go`
- [Image handling](https://github.com/go-pdf/fpdf/blob/main/png.go): `png.go`

### Optional integrations

- [Barcode integration](https://github.com/go-pdf/fpdf/blob/main/contrib/barcode/barcode.go): `contrib/barcode/barcode.go`
- [PDF page import](https://github.com/go-pdf/fpdf/blob/main/contrib/gofpdi/gofpdi.go): `contrib/gofpdi/gofpdi.go`
- [HTTP images](https://github.com/go-pdf/fpdf/blob/main/contrib/httpimg/httpimg.go): `contrib/httpimg/httpimg.go`
- [TIFF images](https://github.com/go-pdf/fpdf/blob/main/contrib/tiff/tiff.go): `contrib/tiff/tiff.go`

### Other components

- **Go application**
- **Generated PDF**

## Connections

- Go application → PDF document API: uses
- PDF document API → Generated PDF: writes
- PDF document API → Document defaults: uses defaults
- PDF document API → PDF output writer: serializes through
- PDF document API → PDF utilities: uses
- PDF document API → Text and Unicode: supports
- PDF document API → Grid layout: supports
- PDF document API → Basic HTML: supports
- PDF document API → SVG drawing: supports
- PDF document API → Templates: supports
- PDF document API → Embedded files: supports
- PDF document API → PDF layers: supports
- PDF document API → Font handling: supports
- Font handling → TrueType parsing: parses fonts
- Font handling → Bundled font data: uses data
- PDF document API → Image handling: supports
- Barcode integration → PDF document API: registers images (evidence: `contrib/barcode/barcode.go`)
- PDF page import → PDF document API: imports templates (evidence: `contrib/gofpdi/gofpdi.go`)
- HTTP images → PDF document API: registers images (evidence: `contrib/httpimg/httpimg.go`)
- TIFF images → PDF document API: registers images (evidence: `contrib/tiff/tiff.go`)
