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), and PageRange; text and image watermark templates draw over existing content 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
Text watermark FontID accepts a Standard 14 number from 1 through 14 or an existing font handle; preset text anchors use the measured font width and height in a top-left page frame, while wpCustom uses the caller origin and coordinates; text watermark application restores the original page, origin, selected font and drawing state
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 |