We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to add watermark?Aspose.total for java

when we use words to add watermark ,the watermark was not top layer.it is behind pictures.we also setZOrder.but it is still so.

hope you supply us total product for adding watermark including add picture watermark

Hi Xu,

Thanks for your inquiry. The problem occurs because watermark shape resides inside header footer story and main content/elements are inside body story (please see Story class). If you insert a watermark using Microsoft Word 2013 in source document, you will observe the same behaviour. However, you can overcome this problem by manually inserting watermarks in each Page. You can achieve this by moving the cursor to the first Paragraph in each Page of your document and then making those Paragraphs as an anchor points for your watermarks (See LayoutCollector class).

Best regards,

can you give some exapmles?

Hi Xu,

Thanks for your inquiry. You can try using the following code:

public static void InsertWatermarkTextAtEachPage(Document doc, string watermarkText)
    DocumentBuilder builder = new DocumentBuilder(doc);
    PageSetup ps = builder.PageSetup;
    NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
    LayoutCollector collector = new LayoutCollector(doc);
    Paragraph anchorPara = null;
    int pageIndex = 1;
    foreach (Paragraph para in paragraphs)
        if (collector.GetStartPageIndex(para) == pageIndex && para.GetAncestor(NodeType.GroupShape) == null)
            anchorPara = para;
            Shape watermark = new Shape(doc, Aspose.Words.Drawing.ShapeType.TextPlainText);
            watermark.TextPath.Text = watermarkText;
            watermark.TextPath.FontFamily = "Arial";
            watermark.Width = 300;
            watermark.Height = 70;
            watermark.Left = 100;
            watermark.Top = 100;
            watermark.Rotation = -40;
            watermark.Fill.Color = Color.Gray;
            watermark.StrokeColor = Color.Gray;
            watermark.Name = string.Format("WaterMark_{0}", Guid.NewGuid());
            watermark.WrapType = WrapType.None;

I hope, this helps.

In case you face any problems, please attach your input Word document and output Word document showing the undesired behavior here for testing. We will investigate the issue on our end and provide you more information.

Best regards,