Free Support Forum - groupdocs.com

How to add watermark to images in a document using .NET

Hi
I am using this code to add water mark to word documents

using (Watermarker watermarker = new Watermarker(stream, new GroupDocs.Watermark.Options.LoadOptions(password)))
{

                // Use path to the image as constructor's parameter
                using (ImageWatermark watermark = new ImageWatermark(ImagePath))
                {
                    watermark.HorizontalAlignment = GroupDocs.Watermark.Common.HorizontalAlignment.Center;
                    watermark.VerticalAlignment = VerticalAlignment.Center;
                    watermark.SizingType = SizingType.ScaleToParentArea;
                   
                   watermarker.Add(watermark);
                    

                }
                // Save the resultant document
                watermarker.Save();
            }

the problem is when document is having any image, watermark is not visible on image.
rest of the text document it is fine.
Capture.PNG.jpg (74.5 KB)
see the attached image for more details.

Please let me know is there a way to overcome this

@tilankak

As per the code you shared above, you are adding image watermark. However, we’re investigating how to put text signature on top of the image in any Word file. Your investigation ticket ID is WATERMARKNET-1330. We’ll notify you in case of any update.

@tilankak

If we add watermark without any options, it becomes part of the header/footer, whose precedence for displaying is very low.
The watermark will be visible if it is part of the page text. So, you need to use WordProcessingWatermarkPagesOptions as follows:

using (Watermarker watermarker = new Watermarker(@"D:/sample.docx"))
{ 
	TextWatermark textWatermark = new TextWatermark("This is an artifact watermark", new Font("Arial", 8));
	textWatermark.HorizontalAlignment = HorizontalAlignment.Center;
	textWatermark.VerticalAlignment = VerticalAlignment.Center;
	textWatermark.ForegroundColor = Color.Red;
	WordProcessingWatermarkPagesOptions options = new WordProcessingWatermarkPagesOptions()
	{
		PageNumbers = new int[] { 1 }
	};
	watermarker.Add(textWatermark, options); 
	watermarker.Save(@"D:/output.docx");
}