Documentation
¶
Overview ¶
Package pdf is togo's HTML→PDF plugin. It exposes a swappable Renderer driver (default: headless Chromium via chromedp), a Go API pdf.Render(...), and a REST endpoint POST /api/pdf. Drivers register via pdf.RegisterDriver; pick one with PDF_DRIVER (default "chromium").
Install: `togo install togo-framework/pdf` (blank-import registers it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDriver ¶
func RegisterDriver(name string, f DriverFactory)
RegisterDriver registers a PDF engine by name (call from a plugin's init()).
Types ¶
type DriverFactory ¶
DriverFactory builds a Renderer from the kernel (env-configured).
type Options ¶
type Options struct {
// URL renders a live page instead of the HTML body when set.
URL string `json:"url,omitempty"`
// Landscape orientation. Default false (portrait).
Landscape bool `json:"landscape,omitempty"`
// PrintBackground includes background graphics. Default true.
PrintBackground *bool `json:"printBackground,omitempty"`
// Paper size in inches (PaperWidth x PaperHeight). 0 = A4 (8.27 x 11.69).
PaperWidth float64 `json:"paperWidth,omitempty"`
PaperHeight float64 `json:"paperHeight,omitempty"`
// Margins in inches.
MarginTop, MarginBottom, MarginLeft, MarginRight float64 `json:"-"`
// Scale of the page rendering (0.1–2). 0 = 1.0.
Scale float64 `json:"scale,omitempty"`
// TimeoutSeconds caps a render. 0 = 30s.
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
}
Options tune a render. Zero values fall back to driver defaults (A4, default margins).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the pdf runtime stored on the kernel (k.Get("pdf")).
func FromKernel ¶
FromKernel fetches the pdf service from the kernel container.