examples/

directory
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 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)
├── 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)
├── 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
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 using the html.ConvertFull API.
HTML-to-PDF demonstrates converting a rich HTML document with CSS into a polished, multi-page PDF using the html.ConvertFull API.
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.
Links demonstrates all link-related features in Folio:
Links demonstrates all link-related features in Folio:
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.
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.
ZUGFeRD demonstrates creating a PDF/A-3B compliant invoice with an embedded Factur-X/ZUGFeRD XML file attachment.

Jump to

Keyboard shortcuts

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