Free Support Forum - aspose.com

Incorrect watermark in generated PDF

We are also facing this issue. Hopefully there will be a fix soon, please prioritize.

@arcomoperations,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output document showing the undesired behavior
  • Your expected Word document showing the correct output. You can create this document by using MS Word.
  • Please create a standalone simplified console application (source code without compilation errors) that helps us reproduce your specific problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start further investigation into your issues and provide you more information. Thanks for your cooperation.

https://drive.google.com/open?id=1wrj3-NnEVIA2ohLRhAgBekTwjUeB5gQc
file size limit preventing upload.

@arcomoperations,

We are working over your query and will get back to you soon.

@arcomoperations,

Thanks for your patience.

Please note that Word for Mac has some difficulties with VML shapes, so in order to create correct output for Mac Word, please change ShapeType.TextPlainText to ShapeType.TextBox in your code. Please check the following modified code. Hope this helps you.

public static void ApplyWaterMark(Document doc, string watermarkText, double top)
{
    Run text = new Run(doc, watermarkText);
    text.Font.Size = 7;
    text.Font.Name = "Calibri";
    text.Font.NoProofing = true;

    Paragraph watermarkTextPara = new Paragraph(doc);
    watermarkTextPara.AppendChild(text);

    Shape watermark = new Shape(doc, ShapeType.TextBox);
    watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
    watermark.Width = 500;
    watermark.Height = 10;
    watermark.Top = top;
    watermark.TextBox.InternalMarginBottom = 0;
    watermark.TextBox.InternalMarginTop = 0;
    watermark.TextBox.InternalMarginLeft = 0;
    watermark.Stroked = false;
    watermark.WrapType = WrapType.None;
    watermark.AppendChild(watermarkTextPara);

    Paragraph watermarkPara = new Paragraph(doc);
    watermarkPara.AppendChild(watermark);

    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.FooterPrimary);
        insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.FooterFirst);
        insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.FooterEven);
    }
}

public static void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, HeaderFooterType headerType)
{
    HeaderFooter header = sect.HeadersFooters[headerType];
    if (header == null)
    {
        header = new HeaderFooter(sect.Document, headerType);
        sect.HeadersFooters.Add(header);
    }
    header.AppendChild(watermarkPara.Clone(true));
}