[]
        
(Showing Draft Content)

Watermark Annotation

A watermark annotation defines graphics that is expected to be printed at a fixed size and position on a page, regardless of the dimensions of the printed page. DsPdf provides WatermarkAnnotation class to enable the users to apply watermark annotations to the PDF file.

DsPdf demonstrating how to add watermark annotation in a PDF document

Note: If both Text and Image properties are specified, then Image property is used as watermark content.

Refer to the following example code to add a watermark annotation to a PDF document:

public void CreateWatermarkAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    var fs = new FileStream(Path.Combine("CompleteJavaScriptBook.pdf"), FileMode.Open, FileAccess.Read);
    doc.Load(fs);  //Load the document

    //Loop over pages, add a watermark to each page:
    foreach (var page in doc.Pages)
    {
        //Create an instance of WatermarkAnnotation class and set its relevant properties
        var watermark = new WatermarkAnnotation()
        {
            PdfRect = new RectangleF(50, 300, 500, 150),
            Image = Image.FromFile("draft-copy.png"),
            Page = page // Add watermark to page                
        };
        doc.Save("WatermarkAnnotation.pdf");
    }

}