@nextgensoftwares/folio-plugin-watermark
Text and image watermarks as a page layer: on screen, in PDF and as Word's native watermark. Guide: Watermark plugin.
Plugin
| Export | Signature | Description |
|---|---|---|
watermarkPlugin | (options?: WatermarkPluginOptions) => WatermarkPlugin | one pageLayers entry, the watermark painter, PDF/DOCX exporters and a settings section |
type WatermarkPluginOptions | WatermarkOptions plus settings?: boolean | { slot?, order?, label? } (default: a "Watermark" section in the settings slot) | |
type WatermarkPlugin | FolioPlugin plus setOptions(patch), replaceOptions(options), getOptions(), resolved(), subscribe(fn) |
Options
| Export | Description |
|---|---|
WatermarkOptions | enabled, text, image, color, opacity (0..1, default 0.15), angle (degrees clockwise, default -45), position, tile, count (1..50 copies per page), countLayout ('grid' / 'diagonal'), pages, targets, z ('under' / 'over'), variables |
WatermarkText | { content, fontFamily?, fontSize?, fontWeight?, italic? }; content takes , , and host variables |
WatermarkImage | { src, width?, height? } (px; drawn contained in the box) |
WatermarkTile | { gap? } px between tiles (default 80) |
WatermarkPosition | 'center' | 'top' | 'bottom' | { x, y } (page fractions) |
WatermarkPages | 'all' | 'first' | 'odd' | 'even', page numbers and [from, to] ranges, or (page, total) => boolean |
WatermarkAttrs | the validated attributes of a watermark fragment (kind: 'text' | 'image') |
WATERMARK_TYPE | 'watermark', the custom fragment type |
Validation
| Export | Description |
|---|---|
resolveOptions(options) | untrusted options → ResolvedWatermark (clamped numbers, safe colour/font/src, capped text and ranges); never throws |
ResolvedWatermark | the config fragments are built from |
safeImageSrc(src) | http(s), blob:, relative paths and data:image/(png|jpeg|gif|webp|bmp), else null |
LIMITS | text length, src length, font/image size, gap, tiles per page (400), count copies per page (50), variables |
normalizePages(rule), pageMatches(rule, page, total) | page rules (a throwing predicate counts as false) |
Fragments and painters
| Export | Description |
|---|---|
watermarkFragments(cfg, page, ctx) | the fragments of one page; reads only the page box and numbers |
tileCentres(page, item, angle, gap, max?) | brick-pattern tile centres, at most max |
countPlacement(page, item, angle, count, layout?), gridShape(count, page), CountLayout | count copies: centres plus the scale (≤ 1) that fits each copy in its cell; grid columns × rows shaped like the page |
fillTemplate(template, vars) | substitution (unknown names → empty) |
WatermarkPainter, watermarkPainters | React painter: rotated text or a contained image, pointer-events: none, not selectable |
canvasWatermarkPainter, CanvasWatermarkContext | canvas painter (exporters.canvas) for baked pages and server images: same geometry, drawn into the page pixels |
pdfWatermarkPainter, PdfWatermarkContext | PDF painter: real glyphs, rotation about the box centre, ExtGState opacity |
docxWatermarkExporter, DocxWatermarkSpec, hexOf | DOCX layer exporter returning a DocxWatermark for @nextgensoftwares/folio-export-docx; CSS colour → RRGGBB |
createSettingsPanel(plugin), parseRanges(text) | the settings section component; "1, 3-5" → [1, [3, 5]] |