Free Support Forum - groupdocs.com

How to make text watermark display on top of the images in word document using .NET

[Product version: GroupDocs.Watermark.NET 20.7.0]

I’ve tried setting TextWatermark.IsBackground = false, but it’s not working, watermark still got covered by the images.
image.jpg (86.1 KB)

@wangfu91

We’ve reproduced this issue at our end. Hence, it’s been logged in our internal issue tracking system with ID WATERMARKNET-1301 for further investigation and resolution. As there’s any update, you will be notified.

@wangfu91

To place a watermark on top of the page content, you have to add a watermark to the page (not a section as by default), you may find following code helpful:

using (Watermarker watermarker = new Watermarker(stream))
{
    TextWatermark watermark = new TextWatermark("Confidential", new Font("Arial", 24));

    watermark.HorizontalAlignment = HorizontalAlignment.Center;
    watermark.VerticalAlignment = VerticalAlignment.Center;
    watermark.RotateAngle = -45;
    watermark.SizingType = SizingType.ScaleToParentDimensions;
    watermark.ScaleFactor = 1;
    watermark.Opacity = 0.4;
    watermark.IsBackground = false;

    WordProcessingWatermarkPagesOptions options = new WordProcessingWatermarkPagesOptions();
    options.PageNumbers = GetAllPageNumbers(watermarker.GetContent<WordProcessingContent>());
    watermarker.Add(watermark, options);

    watermarker.Save(@"D:/output.docx");
}

private static int[] GetAllPageNumbers(WordProcessingContent content)
{
    int[] numbers = new int[content.PageCount];
    for (int i = 0; i < content.PageCount; i++)
    {
        numbers[i] = i + 1; // this is a number, not an index
    }
    return numbers;
}