Documentation
¶
Overview ¶
Package pdf renders structured text lines into a minimal, valid PDF 1.4 document using only the standard library. It uses the standard 14 fonts (Helvetica, Helvetica-Bold, Courier) with WinAnsiEncoding, performs simple word wrapping and pagination, and emits an uncompressed cross-reference table so that any conforming reader accepts the output.
It is intentionally small: there is no layout engine, no images and no compression. The goal is to give a browser engine a Page.pdf-like capability from an already extracted text outline of a page.
Index ¶
Constants ¶
const ( DefaultPageWidthPt = 595.28 DefaultPageHeightPt = 841.89 DefaultMarginPt = 48 DefaultBaseFontPt = 10.5 )
Default geometry (A4 portrait).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Line ¶
Line is one logical block of text to render.
Kind selects the style. Recognised kinds are "h1", "h2", "h3", "p", "li", "link", "input", "button", "pre", "hr" and "" (treated like "p"). Indent is a nesting depth that shifts the block to the right. Href is used for "link" lines; an absolute http(s) URL produces a clickable /Link annotation.
type Options ¶
type Options struct {
Title string
URL string
PageWidthPt float64
PageHeightPt float64
MarginPt float64
BaseFontPt float64
Landscape bool
}
Options controls page geometry and decoration.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the recommended options: A4, 48 pt margins, 10.5 pt Helvetica, header and footer enabled. Render fills in zero numeric fields with these defaults; HeaderFooter is a plain bool, so a zero Options renders without the running header and footer.