Need a different watermark per page

We have a solution that needs to insert different full page watermarks per page. If building a single document inserting the watermarks in the headers using BehindText=True works. The problem comes in the solution also must be able to merge documents with differing watermarks together and still keep all the different watermarks. If we merge in a document that happens to not have any headers the headers from the previous document are automatically merged in.
To fix this I tried inserting the watermark in the body of the document instead. This prevented the merge feature from attempting to repeat headers that I didn’t want in another document, but now the BehindText=True only affects the text of the document so the footer is lost behind the image.
Is there a way around this that I’m not seeing?

Watermark code:
_builder.MoveTo(_document.Sections(_document.Sections.Count - 1).Body.FirstParagraph)
Dim watermark = _builder.InsertImage(img, _builder.PageSetup.PageWidth, _builder.PageSetup.PageHeight)
watermark.BehindText = True
watermark.AlternativeText = AsposeDocument.LogoAlternativeText
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page
watermark.WrapType = WrapType.None
watermark.VerticalAlignment = VerticalAlignment.Center
watermark.HorizontalAlignment = HorizontalAlignment.Center
watermark.ImageData.Title = “DynamicBranding”

Hi Eric,


Thanks for your inquiry. Please note that MS Word document is flow document and does not contain any information about its layout into lines and pages. Therefore, technically there is no “Page” concept in Word document. Pages are created by Microsoft Word on the fly.
Aspose.Words uses our own Rendering Engine to layout documents into pages. Please check using the DocumentLayoutHelper sample from the offline samples pack. This sample demonstrates how to easily work with the layout elements of a document and access the pages, lines, rows, spans etc.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate, how you want your final Word output be generated like. We will then provide you more information on this along with code.

Ok, it’s not possible to do what I want in Word, so Aspose can’t do it either. This makes sense. I’ll post the problem I was trying to solve in another thread, maybe there is another way to solve this problem.

Hi Eric,


Thanks for your feedback. You can insert different watermark at each page of document by inserting image in the header of each section. In this case, you have to insert section break of type NewPage at the end of each page of document.

Please check using the DocumentLayoutHelper sample from the offline samples pack. It would be great if you please share your input word document along with expected output document here. We will then provide you more information on this along with code. Please also share how many watermark images you will have for a document?

Moreover, please not that the HeaderFooter represents a container for the header or footer text of a section. HeaderFooter is a section-level node and can only be a child of Section. There can only be one HeaderFooter or each HeaderFooterType in a Section.