Add image watermarks

One of the main features of the GroupDocs.Watermark library is adding image watermarks to documents. You may add watermarks to documents or images from local disks, as well as from streams. For a full list of supported document formats, check Supported formats.

To add an image watermark perform the following steps:

  1. Create an instance of the Watermarker class for a local file or file stream;
  2. Create an instance of the ImageWatermark class from the local image file;
  3. (Optionally.) Specify the watermark horizontal and vertical alignments;
  4. Call the Add method to apply the watermark to the document;
  5. Call the Save method to store the document in a new location.
using GroupDocs.Watermark;
using GroupDocs.Watermark.Common;
using GroupDocs.Watermark.Watermarks;

// Specify an absolute or relative path to your document.
using (Watermarker watermarker = new Watermarker("C:\\Docs\\contract.docx"))
    // Specify an absolute or relative path to the desired image
    ImageWatermark watermark = new ImageWatermark("C:\\Docs\\logo.png");
    // Specify watermark size, opacity and alignments
    watermark.Width = 200;
    watermark.Height = 200;
    watermark.Opacity = 0.5;
    watermark.HorizontalAlignment = HorizontalAlignment.Center;
    watermark.VerticalAlignment = VerticalAlignment.Center;
    // Apply the watermark
    // Save the resulting document

Run the program. A new watermarked image will appear in the specified path.

Adding image watermarks

What’s next

GroupDocs.Watermark offers many more capabilities for adding image watermarks. To learn how to add watermarks from streams, use absolute or relative positioning, and so on, see the Adding image watermarks article of the “Advanced usage” section.