I’m losing a footer from my document after adding a watermark. The watermark is an image file. This is happening with Aspose.Words 8.0.0.0.
The code used to add the watermark is that available from the website - as shown below.
Is this a known issue?
I have ataached documents pre-watermark and post-watermark. The footer is no longer present after adding the watermark.
Have you any suggestions?
Many thanks.
public void ApplyWatermark(string imagePath)
{
Shape watermark = new Shape(asposeDocument, ShapeType.Image);
watermark.ImageData.SetImage(imagePath);
watermark.Width = 530;
watermark.Height = 790;
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
Paragraph watermarkPara = new Paragraph(asposeDocument);
watermarkPara.AppendChild(watermark);
foreach(Section sect in asposeDocument.Sections)
{
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);
}
}
private void InsertWatermarkIntoHeader(Paragraph watermarkParagraph, Section sect, HeaderFooterType headerType)
{
HeaderFooter header = sect.HeadersFooters[headerType];
if (header == null)
{
header = new HeaderFooter(sect.Document, headerType);
sect.HeadersFooters.Add(header);
}
header.AppendChild(watermarkParagraph.Clone(true));
}