I am trying to insert a water mark. The code listed below works when I am saving to rtf, but if I saved to PDF it does not work. I remember reading about a bug/feature request I think on this, but could not find it to post to the end of that thread. I am trying to avoid using images, to cut down on the size of the generated files where possible.
Sample of Code I use to insert the watermark follows below.
public void InsertWaterMark(Aspose.Words.DocumentBuilder Builder)
{
//Create whatermark shape
Shape watermark = new Shape(Builder.Document, ShapeType.TextPlainText);
watermark.TextPath.Text = "DRAFT COPY";
watermark.TextPath.FontFamily = "Times New Roman";
// watermark.TextPath.XScale = true;
watermark.Width = 300;
watermark.Height = 100;
watermark.Rotation = -45;
//uncomment the following line if you need solid black text
watermark.Fill.Color = System.Drawing.Color.Gray;
//Set position of watermark
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
//Create new paragraph and append watermark to this paragraph
Paragraph watermarkPar = new Paragraph(Builder.Document);
watermarkPar.AppendChild(watermark);
System.Collections.ArrayList hfTypes = new System.Collections.ArrayList();
hfTypes.Add(HeaderFooterType.HeaderPrimary);
hfTypes.Add(HeaderFooterType.HeaderFirst);
hfTypes.Add(HeaderFooterType.HeaderEven);
//Now we should insert watermark into the header of each section of document
foreach (Section sect in Builder.Document.Sections)
{
foreach (HeaderFooterType hftype in hfTypes)
{
if (sect.HeadersFooters[hftype] == null)
{
//Create new header
if (hftype == HeaderFooterType.HeaderPrimary ||
hftype == HeaderFooterType.HeaderFirst && sect.PageSetup.DifferentFirstPageHeaderFooter ||
hftype == HeaderFooterType.HeaderEven && sect.PageSetup.OddAndEvenPagesHeaderFooter)
{
HeaderFooter hf = new HeaderFooter(Builder.Document, hftype);
//insert clone of watermarkPar into the header
hf.AppendChild(watermarkPar.Clone(true));
sect.HeadersFooters.Add(hf);
}
}
else
{
sect.HeadersFooters[hftype].AppendChild(watermarkPar.Clone(true));
}
}
}
}