How to add watermarks to photo or documents in .NET

What we offer in context of watermarks

Although GroupDocs.Annotation does not specialise specifically in watermarks, we still provide this opportunity to our users. You can add a text watermark to any of the documents we support. You can specify text, choose any font, any colour and size of text, set transparency, angle of text, as well as specify some other useful parameters. You can read more about them here. At the moment, annotation only allows you to create text annotations, but it allows you to do so programmatically, so even offline. We understand that watermarking is a very complex and important task and it is unlikely to be limited to text-only versions. If this is the case, we recommend that you visit our web application dedicated specifically to watermarking.

Check document preview with a watermark on it

Check live preview

Of course, when applying any annotation, especially if it is a watermark, you would probably like to see how it looks on the document. For this purpose we have a web application which we highly recommend to use. It is absolutely free. You can annotate and move the annotation around on the document. It gives the full feeling of working directly inside the document.

Generate preview

You can also check out our article on how to generate previews programmatically via our .NET API. It will guide you how to apply an annotation and immediately generate a preview of your document with it. This can be useful if you’re not sure where and how to put a watermark. In that case you can apply the watermark in different places and generate multiple previews. The generated previews can then be sent to someone for approval.

How to add watermark to any document

Watermark annotation adds text watermark like shown at the picture below. 

There is an ability to specify the next properties for WatermarkAnnotation type:

Follow these steps to add Watermark annotation to document:

  • Instantiate Annotator object with input document path or stream;
  • Instantiate WatermarkAnnotation object with desired properties (position, color, etc);
  • Call Add method and pass WatermarkAnnotation object;
  • Call Save method with resultant document path or stream.

The following code demonstrates how to add WatermarkAnnotation to the document:

//Add watermark annotation to the document from local disk
using (Annotator annotator = new Annotator("input.pdf"))
{
	WatermarkAnnotation watermark = new WatermarkAnnotation
    {
    	Angle = 75,
        Box = new Rectangle(200, 200, 100, 50),
        CreatedOn = DateTime.Now,
        Text = "Watermark",
        FontColor = 65535,
        FontSize = 12,
        Message = "This is watermark annotation",
        Opacity = 0.7,
        AutoScale = true,
        HorizontalAlignment = HorizontalAlignment.Center,
        VerticalAlignment = VerticalAlignment.Center,
        Replies = new List<Reply>
        {
        	new Reply
            {
            	Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
            	Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    };
    annotator.Add(watermark);
    annotator.Save("result.pdf");
} 

Conclusion

In short, we have learned how to work with watermark using GroupDocs.Annotation .NET API. We have described two options of how you can preview watermark on the document. Moreover, we have offered another resource that extends out functionality - GroupDocs.Watermark. Now, you should have enoughh knowledge to start manipulating with watermark using our GroupDocs .NET API.

More resources

Advanced Usage Topics

To learn more about document annotating features, please refer to the advanced usage section.

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.

© Aspose Pty Ltd 2001-2022. All Rights Reserved.