Skip to content
Guides

Add Text Watermark

The steps to add a text watermark are as follows:

  1. Initialize a CPDFWatermark object, specifying the watermark type as text.

  2. Set the properties required for the text watermark, including content, font, color, and font size.

  3. Set the general properties for the watermark.

  4. Create the watermark in the document.

This example shows how to add a text watermark:

C#
// Initialize the `CPDFWatermark` object, specifying the type as text.
CPDFWatermark watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
// Set the properties for text content, font, color, and font size.
watermark.SetText("test");
watermark.SetFontName("Helvetica");
byte[] color = { 255, 0, 0 };
// Configure the properties required for the text watermark, including content, font, color, and font size.
watermark.SetPages("0-3");
watermark.SetTextRGBColor(color);
watermark.SetScale(2);
watermark.SetRotation(0);
watermark.SetOpacity(120);
watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER);
watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER);
watermark.SetVertOffset(0);
watermark.SetHorizOffset(0);
watermark.SetFront(true);
watermark.SetFullScreen(true);
watermark.SetVerticalSpacing(10);
watermark.SetHorizontalSpacing(10);
// Create the watermark in the document.
watermark.CreateWatermark();