Packages
Search packages... ⌘K
Go Package pdf
PDF generation — HTML-to-PDF rendering with template support
Go Ready SI
PDF Generation
$ gen := pdf.NewGenerator()
[pdf] renderer: chromium (headless)
$ gen.FromTemplate(ctx, "invoice", invoiceData)
[pdf] template: invoice
[pdf] rendering HTML — 3 pages
[pdf] page size: A4 (210x297mm)
[pdf] applying print stylesheet
[pdf] generated — 142 KB, 3 pages
About
Generates PDF documents from HTML templates using a headless browser renderer. Supports page size configuration, header/footer templates, and CSS print media rules for professional document output.
Public API
| Name | Kind | Signature |
|---|---|---|
| Generator | type | type Generator struct |
| NewGenerator | func | func NewGenerator(opts ...Option) *Generator |
| FromHTML | func | func (g *Generator) FromHTML(ctx context.Context, html string, opts ...RenderOption) ([]byte, error) |
| FromTemplate | func | func (g *Generator) FromTemplate(ctx context.Context, tmpl string, data any, opts ...RenderOption) ([]byte, error) |
Related Packages
webassets Go Ready
Image processing pipeline — resize, optimize, format conversion via sips/ImageMagick
imagesresizeoptimizationsipsimagemagick
5 exports 2 deps
external Go Ready
External process runner — exec.Command wrapper with timeout, output capture, error handling
execprocess-runnertimeoutoutput-capture
5 exports 7 deps
Source
github.com/shredbx/sbx-core/pkg/pdf
pdfhtml-to-pdftemplatesrendering