Hi,
we are using aspose-word licensed version 14.12.0.0. I would like to integrate a watermark into a word document. We are facing two types of issue.
- Watermark is shown on all pages in top of page.
- Some of the pages watermark displayed in twice.
First issue, I need watermark is shown center of the pages and second issue, only one watermark shown in the pages instead of twice.
Is there any way to avoid this behavior. How can i achieve this?. Also we attached the same project and screenshot for your review and process to quick solution.
Note: Please include the dll aspose-word version 14.12.0.0.
We are using following code for watermark.
Aspose.Words.Document doc = new Aspose.Words.Document(outStream);
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.WrapType = WrapType.None;
anchorPara.AppendChild(watermark);
pageIndex++;
}
doc.Save(outStream, SaveFormat.Docx);
WaterMarkIssue.zip (458.4 KB)
WaterMark.jpg (50.5 KB)
WaterMark1.jpg (46.1 KB)