API referenceText

pdfSetWatermarkText

Configure a diagonal text watermark stamped on every page

CategoryDocument decoration
Exported namespdfSetWatermarkTextA, pdfSetWatermarkTextW, pdfSetWatermarkText
Notedeferred 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

C
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);
Delphi
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

ParameterTypeDescription
IPDFPPDFInstance handle.
TextstringWatermark 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.
FontSizeDouble<= 0 is replaced with 48.
ColorCardinalFill color (engine's packed color format).
AngleDoubleRotation in degrees.
OpacityDoubleClamped 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 alsopdfSetTrialMode, pdfIsLicensed

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Text
Category

Setters

Exported names

pdfSetWatermarkTextW pdfSetWatermarkText pdfSetWatermarkTextA

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.