Documentation
¶
Overview ¶
Package settings parses the renderSettings JSON accepted by the wasm entrypoint (cmd/wasm). It is a separate, build-tag-free package so the parsing logic can be unit-tested on the host toolchain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Margins ¶
type Margins struct {
Top float64 `json:"top"`
Right float64 `json:"right"`
Bottom float64 `json:"bottom"`
Left float64 `json:"left"`
}
Margins holds page margins in PDF points. It unmarshals from either a single JSON number (applied to all four sides) or an object with any of top/right/bottom/left.
func (*Margins) UnmarshalJSON ¶
UnmarshalJSON accepts 36 or {"top":36,"left":18,...}.
type Settings ¶
type Settings struct {
PageSize string `json:"pageSize"` // named size, e.g. "a4", "letter" (default letter)
Orientation string `json:"orientation"` // "portrait" (default) or "landscape"
Margins *Margins `json:"margins,omitempty"`
MediaType string `json:"mediaType"`
PdfProfile string `json:"pdfProfile"`
PdfTitle string `json:"pdfTitle"`
PdfAuthor string `json:"pdfAuthor,omitempty"`
PdfSubject string `json:"pdfSubject,omitempty"`
PdfKeywords string `json:"pdfKeywords,omitempty"`
IgnoreResourceErrors bool `json:"ignoreResourceErrors"`
CssDpi int `json:"cssDpi"`
Watermark string `json:"watermark,omitempty"` // optional watermark text
HeaderHTML string `json:"headerHtml,omitempty"` // HTML for page header
// Asset / font resolution (issue #426).
AllowAbsolutePaths bool `json:"allowAbsolutePaths"` // permit absolute OS paths in the document (default false)
BaseDir string `json:"baseDir,omitempty"` // directory used as BaseFS root for relative asset paths
FallbackFontPath string `json:"fallbackFontPath,omitempty"` // Unicode fallback font path (BaseFS-relative or absolute)
FallbackFontData string `json:"fallbackFontData,omitempty"` // base64-encoded TTF/OTF used as the Unicode fallback font
}
Settings is the renderSettings JSON accepted by folioRender.
func (Settings) ApplyOptions ¶
ApplyOptions wires the asset-resolution settings into html.Options: baseDir becomes BaseFS (via os.DirFS), allowAbsolutePaths is passed through, and the fallback font is set from fallbackFontData (base64, takes precedence) or fallbackFontPath. Defaults stay safe: with no settings, BaseFS is nil and absolute paths are denied.
func (Settings) ResolvePageSize ¶
ResolvePageSize maps the named page size (defaulting to US Letter) and applies the orientation, swapping dimensions for landscape.