[]
        
(Showing Draft Content)

Watermark

Watermarks are one of the ways to add security to your documents that contain highly confidential information or can be used to verify if a PDF document is a copy or original, or from the authorized company. These are similar to stamps but cannot be moved or changed like stamps. For more information on watermarks, see PDF specification 1.7 (Section 12.5.6.22).

GcPdf library provides easy mechanism to add watermarks to your PDF documents with WatermarkAnnotation class and provides additional properties to enhance them.

Watermark

Add Watermark

To add a watermark in a PDF document, use the WatermarkAnnotation class. The WaterMarkAnnotation class provides the essential properties for creating an image based watermark.

To add a watermark:

  1. Create an object of GcPdfDocument and WaterMarkAnnotation class.

  2. Set the required properties of WaterMarkAnnotation object.

  3. Call the Add method to add the watermark on the page.

    Note: If both Annotations.WatermarkAnnotation.Text and Annotations.WatermarkAnnotation.Image are specified then WatermarkAnnotation.Image is used as watermark content.

    public void CreatePDF(Stream stream)
    {
        GcPdfDocument doc = new GcPdfDocument();
        var page = doc.NewPage();
        var g = page.Graphics;
    
        TextFormat tf = new TextFormat()
        {
            Font = StandardFonts.HelveticaBold,
            FontSize = 72
        };
    
        var watermark = new WatermarkAnnotation()
        {
            Name = "WaterMark Sample",
            Image = Image.FromFile(@ "puffins.jpg"),
            Rect = new RectangleF(100.5F, 110.5F, 500, 250),
            TextFormat = tf,
            Text = "DraftCopy",
        };
    
        // Add watermark to page
        page.Annotations.Add(watermark);
        doc.Save(stream);
    }