examples/

directory
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0

README

Examples

Each subdirectory is a self-contained example that produces a PDF.

Running

go run ./examples/hello

Structure

examples/
├── hello/          # minimal one-page PDF
├── rtl/            # right-to-left script shaping (Arabic, Hebrew)
├── indic/          # Indic script shaping (Devanagari first)
├── cjk/            # Chinese, Japanese, Korean with font subsetting
├── fonts/          # standard, custom, and Unicode fonts (CJK, Cyrillic)
├── barcodes/       # QR Code (all ECC levels), Code 128, and EAN-13
├── links/          # hyperlinks, bookmarks, internal navigation
├── forms/          # interactive AcroForm fields (text, checkbox, radio, dropdown)
├── html-to-pdf/    # rich HTML+CSS report (flexbox, tables, page breaks)
├── import-page/    # load existing PDF as template, add content on top
├── merge/          # parse, merge, and extract text from PDFs
├── redact/         # permanently remove sensitive text (SSNs, emails, PII)
├── report/         # multi-page report with layout API (tables, lists, columns)
├── table-rowspan/  # table cells spanning multiple rows and columns
├── sign/           # PAdES digital signature with self-signed certificate
├── zugferd/        # PDF/A-3B invoice with Factur-X XML attachment
└── README.md

Adding an example

  1. Create a new directory under examples/ (e.g., examples/invoice/).
  2. Add a single main.go that produces one PDF.
  3. Include any required data files in the same directory (XML, images, etc.).
  4. Keep it self-contained — no shared code between examples.
  5. Add a doc comment at the top of main.go describing what the example does and how to run it.
  6. Add the directory to the structure list above.

Directories

Path Synopsis
Barcodes renders every barcode format Folio supports into a single PDF: QR Code (at all four error-correction levels), Code 128, and EAN-13.
Barcodes renders every barcode format Folio supports into a single PDF: QR Code (at all four error-correction levels), Code 128, and EAN-13.
CJK demonstrates PDF generation with Chinese, Japanese, and Korean text.
CJK demonstrates PDF generation with Chinese, Japanese, and Korean text.
Fonts demonstrates PDF generation with multiple fonts: the 14 standard PDF fonts, custom embedded fonts via @font-face, and Unicode text including Chinese, Russian, and Japanese.
Fonts demonstrates PDF generation with multiple fonts: the 14 standard PDF fonts, custom embedded fonts via @font-face, and Unicode text including Chinese, Russian, and Japanese.
Forms demonstrates creating a PDF with interactive AcroForm fields:
Forms demonstrates creating a PDF with interactive AcroForm fields:
Hello creates a one-page PDF with a heading and a paragraph.
Hello creates a one-page PDF with a heading and a paragraph.
HTML-to-PDF demonstrates converting a rich HTML document with CSS into a polished, multi-page PDF via html.ConvertFull + Document.AddConvertResult.
HTML-to-PDF demonstrates converting a rich HTML document with CSS into a polished, multi-page PDF via html.ConvertFull + Document.AddConvertResult.
Import-page demonstrates loading an existing PDF as a template and adding dynamic content on top — the standard workflow for invoices, receipts, certificates, and forms.
Import-page demonstrates loading an existing PDF as a template and adding dynamic content on top — the standard workflow for invoices, receipts, certificates, and forms.
Indic demonstrates OpenType shaping for Brahmic scripts.
Indic demonstrates OpenType shaping for Brahmic scripts.
Invoice example — generates a professional invoice PDF from HTML+CSS.
Invoice example — generates a professional invoice PDF from HTML+CSS.
Legal-numbering demonstrates multi-level clause numbering in a legal agreement using native CSS counters — no markup workarounds:
Legal-numbering demonstrates multi-level clause numbering in a legal agreement using native CSS counters — no markup workarounds:
Links demonstrates all link-related features in Folio:
Links demonstrates all link-related features in Folio:
List-styling demonstrates rich <li> content and styled list-item boxes in HTML→PDF conversion:
List-styling demonstrates rich <li> content and styled list-item boxes in HTML→PDF conversion:
Merge demonstrates reading, merging, and inspecting PDF documents:
Merge demonstrates reading, merging, and inspecting PDF documents:
Optimize compares the default writer with the optimized writer (cross-reference streams per ISO 32000-1 §7.5.8 plus object streams per ISO 32000-1 §7.5.7, orphan sweep over §7.5.4 reachability, and Flate recompression of eligible payloads per §7.4.4) across several document shapes and reports the byte-size delta for each.
Optimize compares the default writer with the optimized writer (cross-reference streams per ISO 32000-1 §7.5.8 plus object streams per ISO 32000-1 §7.5.7, orphan sweep over §7.5.4 reachability, and Flate recompression of eligible payloads per §7.4.4) across several document shapes and reports the byte-size delta for each.
Redact demonstrates permanently removing sensitive content from PDFs.
Redact demonstrates permanently removing sensitive content from PDFs.
Report demonstrates building a multi-page business document using the Go layout API directly — no HTML involved.
Report demonstrates building a multi-page business document using the Go layout API directly — no HTML involved.
RTL demonstrates Right-To-Left text support: Hebrew bidi, Arabic contextual shaping, the rlig lam-alef ligature, GPOS mark-to-base attachment for harakat, kashida justification, and ActualText round-trip for accessibility and copy/paste.
RTL demonstrates Right-To-Left text support: Hebrew bidi, Arabic contextual shaping, the rlig lam-alef ligature, GPOS mark-to-base attachment for harakat, kashida justification, and ActualText round-trip for accessibility and copy/paste.
Sign demonstrates digitally signing a PDF with a PAdES B-B signature.
Sign demonstrates digitally signing a PDF with a PAdES B-B signature.
Table-border-collapse demonstrates CSS 2.1 §17.6.2 conflict resolution for border-collapse: collapse tables: the wider border on a shared edge wins, border-style: hidden always suppresses the edge, and style priority (double beats solid) breaks a tie at equal width.
Table-border-collapse demonstrates CSS 2.1 §17.6.2 conflict resolution for border-collapse: collapse tables: the wider border on a shared edge wins, border-style: hidden always suppresses the edge, and style priority (double beats solid) breaks a tie at equal width.
Table-rowspan creates a multi-page PDF demonstrating cells that span multiple rows (rowspan) alongside multi-column spans (colspan), including a long table whose rowspan group is pushed intact across a page break.
Table-rowspan creates a multi-page PDF demonstrating cells that span multiple rows (rowspan) alongside multi-column spans (colspan), including a long table whose rowspan group is pushed intact across a page break.
Example: render a Go html/template to PDF using the tmpl package.
Example: render a Go html/template to PDF using the tmpl package.
ZUGFeRD demonstrates creating a PDF/A-3B compliant invoice with an embedded Factur-X/ZUGFeRD XML file attachment via the zugferd package.
ZUGFeRD demonstrates creating a PDF/A-3B compliant invoice with an embedded Factur-X/ZUGFeRD XML file attachment via the zugferd package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL