I added watermark to existed document using aspose words, but i need watermark on top. All the text and images should be behind it. If any one knows how to achieve it please help me
See the code i have used
private void InsertWatermarkText(Document doc)
{
Shape watermark = new Shape(doc, ShapeType.TextPlainText);
watermark.TextPath.Text = "Watermark Text added using aspose";
watermark.TextPath.FontFamily = "Arial";
watermark.BehindText = false;
watermark.Width = 500;
watermark.Height = 45;
watermark.ZOrder = 1000;
watermark.Rotation = -30;
watermark.Fill.Color = Color.Gray;
watermark.StrokeColor = Color.Gray;
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
// Create a new paragraph and append the watermark to this paragraph.
Paragraph watermarkPara = new Paragraph(doc);
watermarkPara.AppendChild(watermark);
foreach(Section sect in doc.Sections)
{
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);
}
private void InsertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, HeaderFooterType headerType)
{
HeaderFooter header = sect.HeadersFooters[headerType];
if (header == null)
{
// There is no header of the specified type in the current section, create it.
header = new HeaderFooter(sect.Document, headerType);
sect.HeadersFooters.Add(header);
}
header.AppendChild(watermarkPara.Clone(true));
}