Documentation
¶
Overview ¶
Package wasmconvert holds the host-testable HTML→PDF conversion used by the browser WebAssembly bindings in ../../cmd/wasm. Keeping the conversion logic in a plain (non build-tagged) package lets it be unit tested without a wasm runtime, while the syscall/js glue stays a thin wrapper around it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyHTML = errors.New("wasmconvert: html is empty")
ErrEmptyHTML is returned by HTMLToBase64 when the supplied HTML is empty or only whitespace.
var ErrEmptySpec = errors.New("wasmconvert: spec is empty")
ErrEmptySpec is returned by SpecToBase64 when the supplied spec is empty or only whitespace.
Functions ¶
func HTMLToBase64 ¶
HTMLToBase64 renders the given HTML to a PDF and returns it as a base64 string, suitable for handing back to JavaScript. It returns ErrEmptyHTML when html is empty or whitespace-only, propagates any error from generation (including context cancellation), and recovers from any panic in the render tree so the caller (and the wasm goroutine) always survives.
func SpecToBase64 ¶
SpecToBase64 renders a JSON layout spec into a PDF and returns it as base64. It returns ErrEmptySpec for empty input, a wrapped error for invalid JSON or generation failures, and recovers from any panic in the render tree so the caller (and the wasm goroutine) always survives.
Types ¶
type Spec ¶
type Spec struct {
Rows []SpecRow `json:"rows"`
}
Spec is the JSON layout document accepted by SpecToBase64. It mirrors the schema used by the Paper Playground's component-grid editor.
type SpecComp ¶
type SpecComp struct {
Type string `json:"type"`
Style string `json:"style,omitempty"`
Align string `json:"align,omitempty"`
Value string `json:"value,omitempty"`
Label string `json:"label,omitempty"`
Span int `json:"span,omitempty"`
Checked bool `json:"checked,omitempty"`
Soft bool `json:"soft,omitempty"`
Size float64 `json:"size,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Head []string `json:"head,omitempty"`
Rows [][]string `json:"rows,omitempty"`
ColAlign []string `json:"colAlign,omitempty"`
}
SpecComp is one cell: a component plus its column span and presentation hints.