A declarative YAML-to-PDF generation tool and Go library, powered by maroto v2.
Describe your PDF document in YAML — gofolio renders it.
- Human-readable YAML schema for PDF layout
- 12-column grid system (rows, columns)
- Text, image, table, QR code, barcode, and line components
- Reusable named styles
- Per-page headers and footers with
{page}/{total}variables - Schema validation without rendering (
--validate) - Usable as a CLI tool or embedded Go library
go install github.com/techthos/gofolio/cmd/gofolio@latestgofolio -i invoice.yml -o invoice.pdf
gofolio --validate -i report.ymlFlags
| Flag | Description |
|---|---|
-i, --input |
Input YAML file (required) |
-o, --output |
Output PDF file (default: output.pdf) |
--validate |
Validate YAML only, no PDF output |
--verbose |
Print rendering steps |
import "github.com/techthos/gofolio"
doc, err := gofolio.ParseFile("invoice.yml")
err = gofolio.Render(doc, "invoice.pdf")document:
page: ...
styles: ...
header: ...
footer: ...
body: ...page:
size: A4 | A3 | letter
orientation: portrait | landscape
margins:
top: 10
bottom: 10
left: 15
right: 15Named styles reusable by any component via style:.
styles:
heading:
size: 14
bold: true
align: center
color: "#000000"
family: arial | helvetica | courier
normal:
size: 10
family: helvetica| Type | Description |
|---|---|
text |
Text/paragraph |
image |
Local file or remote URL |
row |
12-column grid container |
table |
Tabular data with optional auto page-break |
qrcode |
QR code from a string value |
barcode |
Barcode (code128, code39, ean13, ean8) |
line |
Horizontal divider |
See docs/PROJECT.md for the full schema reference.
document:
page:
size: A4
orientation: portrait
margins: { top: 10, bottom: 10, left: 15, right: 15 }
styles:
heading: { size: 14, bold: true, align: center }
normal: { size: 10, family: helvetica }
header:
- type: text
value: "Acme Corp — Invoice"
style: heading
footer:
- type: text
value: "Page {page} of {total}"
style: normal
body:
- type: table
auto_new_page: true
header_style: heading
row_style: normal
columns:
- { label: "Description", width: 8 }
- { label: "Total", width: 4 }
rows:
- ["Consulting Services", "1,200.00"]
- ["Hosting Setup", "300.00"]More examples in examples/.
MIT