Skip to content

Techthos/gofolio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gofolio

A declarative YAML-to-PDF generation tool and Go library, powered by maroto v2.

Describe your PDF document in YAML — gofolio renders it.


Features

  • 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

Installation

go install github.com/techthos/gofolio/cmd/gofolio@latest

CLI Usage

gofolio -i invoice.yml -o invoice.pdf
gofolio --validate -i report.yml

Flags

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

Library Usage

import "github.com/techthos/gofolio"

doc, err := gofolio.ParseFile("invoice.yml")
err = gofolio.Render(doc, "invoice.pdf")

YAML Schema

Document structure

document:
  page: ...
  styles: ...
  header: ...
  footer: ...
  body: ...

Page

page:
  size: A4 | A3 | letter
  orientation: portrait | landscape
  margins:
    top: 10
    bottom: 10
    left: 15
    right: 15

Styles

Named 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

Components

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.


Example

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/.


License

MIT

About

A declarative YAML-to-PDF generation tool and Go library, powered by maroto v2.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors