public static void InsertWatermarkImageAtEachPage(Document doc, string watermarkImagePath)
DocumentBuilder builder = new DocumentBuilder(doc);
LayoutCollector collector = new LayoutCollector(doc);
Paragraph anchorPara = null;
int pageIndex = 1;
foreach (Section section in doc.Sections)
foreach (Paragraph para in section.Body.Paragraphs)
if (collector.GetStartPageIndex(para) == pageIndex)
anchorPara = para;
Shape watermark = new Shape(doc, Aspose.Words.Drawing.ShapeType.Image);
watermark.Width = 300;
watermark.Height = 300;
watermark.Left = 0;
watermark.Top = 0;
watermark.BehindText = true;
Now we are facing an issue while watermarking documents having table contents covering multiple pages.
In the above method, we are iterating through paragraphs and if the document is having a table covering multiple pages, then the iteration will run only for the page where table starts and it skips remaining pages and continues after the end of the table.
Because of this, watermark is getting missed on pages and this is a matter of concern for us. Our requirement is to have watermark on each page of the document.
Please look into the issue and suggest any possible solution.
I have attached a sample document, with which we can easily recreate this issue with the above mentioned code.