ApplyWatermark
Page layout
Description
Applies a composable watermark template to the selected document. The template is an instance of TPDFlibWatermarkBase (from the PDFlibWatermark unit) and may be a text watermark, an image watermark, a vector shape watermark, or a composite holding a list of sub-watermarks applied recursively.
TPDFlibShapeWatermark stamps a rectangle, circle, ellipse, polygon, Bezier curve chain or straight line with fill and stroke colours, line width and opacity. Rectangles, circles and ellipses size themselves from Width/Height; polygons, curves and lines take their geometry from SetPoints (X,Y pairs local to the shape's top-left corner), so the nine-point Position grid applies to every shape kind.
Each template carries its own Position (one of nine anchor points or wpCustom), Angle, Opacity (0..1), Overlay mode (soOverlay draws on top of existing content, soUnderlay draws beneath), and PageRange. For composite watermarks, children with an empty PageRange inherit the composite's range.
Internally the watermark delegates to StampText / StampImage, so opacity, rotation, layer ordering, and page-range resolution are handled by the same proven path as the stamp APIs.
Syntax
Delphi
Function TPDFlib.ApplyWatermark(Watermark: TPDFlibWatermarkBase): Integer;
Parameters
| Watermark | A watermark template instance (TPDFlibTextWatermark, TPDFlibImageWatermark, or TPDFlibCompositeWatermark). The caller owns the object and must free it after the call |
|---|
Return values
| 0 | No watermark was placed (no document loaded, nil watermark, or empty text/image) |
|---|---|
| >= 1 | The number of pages the watermark was placed on |