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

Free Support Forum - aspose.com

Aspose words shape is printing behind the image


How to bring the shape above the image in aspose words? Code written in C#.

private static void InsertWaterMarkTextToWord(Aspose.Words.Document doc, string watermarkText)
// Create a watermark shape. This will be a WordArt shape.
// You are free to try other shape types as watermarks.
Shape watermark = new Shape(doc, ShapeType.TextPlainText);

// Set up the text of the watermark.
watermark.TextPath.Text = watermarkText;
watermark.TextPath.FontFamily = “Arial”;
watermark.Width = 500;
watermark.Height = 80; //100

// Text will be directed from the bottom-left to the top-right corner.
watermark.Rotation = -40;
// Remove the following two lines if you need a solid black text.
watermark.Fill.Color = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark
watermark.StrokeColor = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark

// Place the watermark in the page center.
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;
watermark.VerticalAlignment = Aspose.Words.Drawing.VerticalAlignment.Center;
watermark.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;

// Create a new paragraph and append the watermark to this paragraph.
Paragraph watermarkPara = new Paragraph(doc);

// Insert the watermark into all headers of each document section.
foreach (Section sect in doc.Sections)
// There could be up to three different headers in each section, since we want
// the watermark to appear on all pages, insert into all headers.
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);

I have attached the sample file. Please help.

Bhaskar V

Hi Bhaskar,

Thanks for your inquiry. It seems the problem occurs because watermark shape resides inside header footer story and images 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, could you please attach your input Word document here for testing? We will investigate the scenario on our end and provide you more information.

Best regards,

I have attached input word document. Please check.

Hi Bhaskar,

Thanks for your inquiry. 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. Here is how you can achieve this:

public static void InsertWatermarkTextAtEachPage(Document doc, string watermarkText)


DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

PageSetup ps = builder.PageSetup;<o:p></o:p>

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);<o:p></o:p>

LayoutCollector collector = new LayoutCollector(doc);<o:p></o:p>

Paragraph anchorPara = null;<o:p></o:p>

int pageIndex = 1;<o:p></o:p>

foreach (Paragraph para in paragraphs)<o:p></o:p>


if (collector.GetStartPageIndex(para) == pageIndex && para.GetAncestor(NodeType.GroupShape) ==null)<o:p></o:p>


anchorPara = para;<o:p></o:p>

Shape watermark = new Shape(doc, Aspose.Words.Drawing.ShapeType.TextPlainText);<o:p></o:p>

watermark.TextPath.Text = watermarkText;<o:p></o:p>

watermark.TextPath.FontFamily = “Arial”;<o:p></o:p>

watermark.Width = 300;<o:p></o:p>

watermark.Height = 70;<o:p></o:p>

watermark.Left = 100;<o:p></o:p>

watermark.Top = 100;<o:p></o:p>

watermark.Rotation = -40;<o:p></o:p>

watermark.Fill.Color = Color.Gray;<o:p></o:p>

watermark.StrokeColor = Color.Gray;<o:p></o:p>

watermark.Name = string.Format(“WaterMark_{0}”, Guid.NewGuid());<o:p></o:p>

watermark.WrapType = WrapType.None;<o:p></o:p>






I hope, this helps.

Best regards,