On this page
Guides
Add Image Watermark
The steps to add an image watermark are as follows:
Initialize a
CPDFWatermark
object, specifying the watermark type as an image.Create a Bitmap based on the image file, setting the image source and scaling for the image watermark.
Set the general properties for the watermark.
Create the watermark in the document.
This example shows how to add an image watermark:
C#
// Initialize a CPDFWatermark object and specify the watermark type as an image.
CPDFWatermark watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
// Set the image source and scaling ratio for the image watermark.
byte[] imageData = new byte[500 * 500];
watermark.SetImage(imageData, 500, 500);
watermark.SetScale(2);
// Set general properties for the watermark.
watermark.SetPages("0-3");
watermark.SetRotation(1);
watermark.SetOpacity(128);
watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER);
watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER);
watermark.SetVertOffset(0);
watermark.SetHorizOffset(0);
watermark.SetFront(false);
watermark.SetFullScreen(true);
watermark.SetVerticalSpacing(10);
watermark.SetHorizontalSpacing(10);
// Create a watermark in the document.
watermark.CreateWatermark();