| Category | Document decoration |
|---|---|
| Exported names | pdfSetWatermarkTextA, pdfSetWatermarkTextW, pdfSetWatermarkText |
| Note | deferred application (see Remarks) |
Purpose — Configure a diagonal text watermark stamped on every page of the output document.
Description — Stores the watermark configuration; FontSize <= 0 is replaced with a default of 48, and Opacity is clamped to [0, 1]. Setting an empty Text disables the watermark (FWmEnabled := Text <> '').
Declarations
BOOL32 __stdcall pdfSetWatermarkTextA(PPDF IPDF, const char* Text, double FontSize, uint32_t Color, double Angle, double Opacity);
BOOL32 __stdcall pdfSetWatermarkTextW(PPDF IPDF, const wchar_t* Text, double FontSize, uint32_t Color, double Angle, double Opacity);
function pdfSetWatermarkTextA(const IPDF: PPDF; Text: PAnsiChar; FontSize: Double; Color: Cardinal; Angle, Opacity: Double): LongBool; stdcall; external 'LumasPdf.dll';
function pdfSetWatermarkTextW(const IPDF: PPDF; Text: PWideChar; FontSize: Double; Color: Cardinal; Angle, Opacity: Double): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Text | string | Watermark text. Supports [page]/[pages] token substitution (case-insensitive) for the current page number and total page count — the same substitution mechanism used by header/footer text. Empty string disables the watermark. |
FontSize | Double | <= 0 is replaced with 48. |
Color | Cardinal | Fill color (engine's packed color format). |
Angle | Double | Rotation in degrees. |
Opacity | Double | Clamped to [0, 1]; values < 1 create a transient ExtGState for transparency. |
Return value — Always TRUE on a valid handle.
Remarks — deferred, document-wide application, always Helvetica. The watermark is not drawn when this call is made. It is applied to every page in the document — including pages already written before this call — during the deferred decoration pass that runs once at close time (guarded by FDecorationsApplied so it only runs once). The watermark font is always Helvetica; there is no way to choose a different font for the watermark text through this API. If the same instance is running in unlicensed trial mode (pdfSetTrialMode(True) and no valid license key), a second, separate "LumasPDF DEMO" stamp is added automatically alongside your watermark on every page — this trial stamp is independent of and unrelated to pdfSetWatermarkText.
See also — pdfSetTrialMode, pdfIsLicensed
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Setters
pdfSetWatermarkTextW
pdfSetWatermarkText
pdfSetWatermarkTextA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.