Documentation
¶
Overview ¶
Package folio is the root façade for the Folio PDF toolkit. It re-exports the most commonly used types and constructors from the document package so callers can depend on a single stable import path for the common "build a document, then write it" flow:
doc := folio.NewDocument(folio.PageSizeA4) // ... add content ... _, err := doc.WriteTo(w)
The exported names are type aliases and function/value re-exports, so they are fully interchangeable with the document package's own identifiers and carry the complete method set — including methods added to document.Document over time.
This façade intentionally covers only the document-construction surface. Specialized APIs keep their own packages: HTML conversion in github.com/carlos7ags/folio/html, the layout engine in .../layout, and font handling in .../font. Reach for those subpackages directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( PageSizeA0 = document.PageSizeA0 PageSizeA1 = document.PageSizeA1 PageSizeA2 = document.PageSizeA2 PageSizeA3 = document.PageSizeA3 PageSizeA4 = document.PageSizeA4 PageSizeA5 = document.PageSizeA5 PageSizeA6 = document.PageSizeA6 PageSizeB4 = document.PageSizeB4 PageSizeB5 = document.PageSizeB5 PageSizeLetter = document.PageSizeLetter PageSizeLegal = document.PageSizeLegal PageSizeTabloid = document.PageSizeTabloid PageSizeLedger = document.PageSizeLedger PageSizeExecutive = document.PageSizeExecutive )
Standard page sizes, re-exported from the document package.
var NewDocument = document.NewDocument
NewDocument creates a new PDF document with the given page size. It is document.NewDocument.
Functions ¶
This section is empty.
Types ¶
type Document ¶
Document is a PDF document under construction. See document.Document.
type EncryptionConfig ¶
type EncryptionConfig = document.EncryptionConfig
EncryptionConfig configures document encryption. See document.EncryptionConfig.
type Info ¶
Info holds document metadata written to the /Info dictionary. See document.Info.
type PageSize ¶
PageSize is a page's dimensions in points. See document.PageSize.
type PdfAConfig ¶
type PdfAConfig = document.PdfAConfig
PdfAConfig configures PDF/A conformance. See document.PdfAConfig.
type WriteOptions ¶
type WriteOptions = document.WriteOptions
WriteOptions controls optional writer behavior. See document.WriteOptions.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package barcode generates 1D and 2D barcodes that can be rendered directly into a PDF content stream as vector graphics (no images).
|
Package barcode generates 1D and 2D barcodes that can be rendered directly into a PDF content stream as vector graphics (no images). |
|
cmd
|
|
|
folio
command
Command folio is a CLI tool for PDF operations.
|
Command folio is a CLI tool for PDF operations. |
|
gen-metrics
command
gen-metrics parses Adobe AFM files and generates Go source for font width and kerning tables.
|
gen-metrics parses Adobe AFM files and generates Go source for font width and kerning tables. |
|
wasm
command
|
|
|
wasm/settings
Package settings parses the renderSettings JSON accepted by the wasm entrypoint (cmd/wasm).
|
Package settings parses the renderSettings JSON accepted by the wasm entrypoint (cmd/wasm). |
|
Package content provides a builder for PDF content streams — the sequences of operators that render text, graphics, and images on a page (ISO 32000 §7.8.2).
|
Package content provides a builder for PDF content streams — the sequences of operators that render text, graphics, and images on a page (ISO 32000 §7.8.2). |
|
Package core implements the fundamental PDF object types defined in ISO 32000 §7.3 — Boolean, Number, String, Name, Array, Dictionary, Stream, and Null — plus indirect references (§7.3.10) and standard security handler encryption (§7.6).
|
Package core implements the fundamental PDF object types defined in ISO 32000 §7.3 — Boolean, Number, String, Name, Array, Dictionary, Stream, and Null — plus indirect references (§7.3.10) and standard security handler encryption (§7.6). |
|
Package document is the top-level API for building PDF files.
|
Package document is the top-level API for building PDF files. |
|
examples
|
|
|
barcodes
command
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
command
CJK demonstrates PDF generation with Chinese, Japanese, and Korean text.
|
CJK demonstrates PDF generation with Chinese, Japanese, and Korean text. |
|
fonts
command
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
command
Forms demonstrates creating a PDF with interactive AcroForm fields:
|
Forms demonstrates creating a PDF with interactive AcroForm fields: |
|
hello
command
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
command
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
command
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
command
Indic demonstrates OpenType shaping for Brahmic scripts.
|
Indic demonstrates OpenType shaping for Brahmic scripts. |
|
invoice
command
Invoice example — generates a professional invoice PDF from HTML+CSS.
|
Invoice example — generates a professional invoice PDF from HTML+CSS. |
|
legal-numbering
command
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
command
Links demonstrates all link-related features in Folio:
|
Links demonstrates all link-related features in Folio: |
|
list-styling
command
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
command
Merge demonstrates reading, merging, and inspecting PDF documents:
|
Merge demonstrates reading, merging, and inspecting PDF documents: |
|
optimize
command
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
command
Redact demonstrates permanently removing sensitive content from PDFs.
|
Redact demonstrates permanently removing sensitive content from PDFs. |
|
report
command
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
command
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
command
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
command
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
command
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. |
|
template
command
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
command
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. |
|
Package export provides a C ABI for the Folio PDF library.
|
Package export provides a C ABI for the Folio PDF library. |
|
Package font handles font loading, parsing, metrics, subsetting, and PDF embedding for TrueType, OpenType, and the 14 standard PDF fonts (ISO 32000 §9.6.2.2).
|
Package font handles font loading, parsing, metrics, subsetting, and PDF embedding for TrueType, OpenType, and the 14 standard PDF fonts (ISO 32000 §9.6.2.2). |
|
Package forms provides AcroForm support for creating and filling interactive PDF form fields (ISO 32000 §12.7).
|
Package forms provides AcroForm support for creating and filling interactive PDF form fields (ISO 32000 §12.7). |
|
Package html converts HTML+CSS markup into layout elements that the github.com/carlos7ags/folio/layout package can render to PDF.
|
Package html converts HTML+CSS markup into layout elements that the github.com/carlos7ags/folio/layout package can render to PDF. |
|
Package image decodes raster images and builds PDF image XObjects (ISO 32000 §8.8.5) for embedding in documents.
|
Package image decodes raster images and builds PDF image XObjects (ISO 32000 §8.8.5) for embedding in documents. |
|
internal
|
|
|
csscolor
Package csscolor parses CSS color values shared by the html and svg packages: named colors, hex, rgb()/rgba(), hsl()/hsla(), and cmyk()/device-cmyk().
|
Package csscolor parses CSS color values shared by the html and svg packages: named colors, hex, rgb()/rgba(), hsl()/hsla(), and cmyk()/device-cmyk(). |
|
cssunit
Package cssunit tokenizes CSS/SVG length values into a numeric value and a unit suffix.
|
Package cssunit tokenizes CSS/SVG length values into a numeric value and a unit suffix. |
|
gen-css-docs
command
Command gen-css-docs writes docs/CSS_SUPPORT.md from the html.cssProperties registry.
|
Command gen-css-docs writes docs/CSS_SUPPORT.md from the html.cssProperties registry. |
|
Package layout implements a high-level, CSS-like element model for building PDF pages from composable building blocks.
|
Package layout implements a high-level, CSS-like element model for building PDF pages from composable building blocks. |
|
Package optimize implements a first rewrite pass for existing PDF files: parse an input document with reader.Parse and re-serialize it through the writer's lossless optimization passes (cross-reference streams, object streams, orphan sweep, stream recompression, and object deduplication — see document.WriteOptions).
|
Package optimize implements a first rewrite pass for existing PDF files: parse an input document with reader.Parse and re-serialize it through the writer's lossless optimization passes (cross-reference streams, object streams, orphan sweep, stream recompression, and object deduplication — see document.WriteOptions). |
|
Package reader parses existing PDF files and provides access to document structure, pages, and content.
|
Package reader parses existing PDF files and provides access to document structure, pages, and content. |
|
Package sign implements PAdES digital signatures for PDF documents per ISO 32000 §12.8 and ETSI TS 102 778.
|
Package sign implements PAdES digital signatures for PDF documents per ISO 32000 §12.8 and ETSI TS 102 778. |
|
Package svg parses SVG markup and renders it into PDF content streams as native vector graphics — no rasterization is involved.
|
Package svg parses SVG markup and renders it into PDF content streams as native vector graphics — no rasterization is involved. |
|
Package tmpl provides Go html/template integration for Folio.
|
Package tmpl provides Go html/template integration for Folio. |
|
unicode
|
|
|
grapheme
Package grapheme implements Unicode extended grapheme cluster segmentation (UAX #29 §3.1.1, rules GB1–GB13).
|
Package grapheme implements Unicode extended grapheme cluster segmentation (UAX #29 §3.1.1, rules GB1–GB13). |
|
Package zugferd generates Factur-X/ZUGFeRD hybrid e-invoices: a typed Invoice renders to UN/CEFACT Cross-Industry Invoice (CII) XML and attaches to a github.com/carlos7ags/folio/document.Document as a PDF/A-3 embedded file, using the primitives in that package (document.FileAttachment, document.PdfAConfig).
|
Package zugferd generates Factur-X/ZUGFeRD hybrid e-invoices: a typed Invoice renders to UN/CEFACT Cross-Industry Invoice (CII) XML and attaches to a github.com/carlos7ags/folio/document.Document as a PDF/A-3 embedded file, using the primitives in that package (document.FileAttachment, document.PdfAConfig). |
