One of the main features of the GroupDocs.Watermark library is adding text 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 a text watermark perform the following steps:
Create an instance of the Watermarker class for a local file or file stream;
Create an instance of the TextWatermark class and specify the desired text and font for the watermark;
Call the Add method to apply the watermark to the document;
Call the Save method to store the document in a new location.
usingGroupDocs.Watermark;usingGroupDocs.Watermark.Common;usingGroupDocs.Watermark.Watermarks;// Specify an absolute or relative path to your document.using(Watermarkerwatermarker=newWatermarker("C:\\Docs\\contract.docx")){// Specify the desired text and font for the watermarkTextWatermarkwatermark=newTextWatermark("Contract Draft",newFont("Arial",60,FontStyle.Bold));// Specify font color and text opacity, rotation and alignmentswatermark.ForegroundColor=Color.DarkGreen;watermark.Opacity=0.5;watermark.HorizontalAlignment=HorizontalAlignment.Center;watermark.VerticalAlignment=VerticalAlignment.Center;// Apply the watermarkwatermarker.Add(watermark);// Save the resulting documentwatermarker.Save("C:\\Docs\\watermarked-contract.docx");}
Run the program. A new watermarked document will appear in the specified path.
What’s next
GroupDocs.Watermark offers many more capabilities for adding text watermarks. For example, it allows specifying background and foreground colors, formatting, text opacity, use of absolute or relative positioning, and so on. To learn more about this, see the Adding text watermarks article of the “Advanced usage” section.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.