Add an image shape to every page of a docx file. But some page of the file has no image background

add an image shape to every page of a docx file. But some page of the file has no image background.

Code

var doc = new Aspose.Words.Document(wordStream);
var builder = new Aspose.Words.DocumentBuilder(doc);
builder.MoveToHeaderFooter(Aspose.Words.HeaderFooterType.HeaderPrimary);
// Insert a floating picture.
var shape = builder.InsertImage(imageStream);
shape.WrapType = Aspose.Words.Drawing.WrapType.None;
shape.BehindText = false;
shape.RelativeHorizontalPosition = Aspose.Words.Drawing.RelativeHorizontalPosition.Page;
shape.RelativeVerticalPosition = Aspose.Words.Drawing.RelativeVerticalPosition.Page;
// Calculate image left and top position so it appears in the centre of the page.
shape.Left = (builder.PageSetup.PageWidth - shape.Width) / 2;
shape.Top = (builder.PageSetup.PageHeight - shape.Height) / 2;
doc.Save(resultStream, Aspose.Words.SaveFormat.Docx);

Hi Louis,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @"AvePoint_Meetings_for_SharePoint_Online_Configuration_Guide+(1).docx");
Watermark(doc, HeaderFooterType.HeaderPrimary);
Watermark(doc, HeaderFooterType.HeaderFirst);
Watermark(doc, HeaderFooterType.HeaderEven);
doc.Save(MyDir + @"16.3.0.docx");
public static void Watermark(Document doc, HeaderFooterType hf)
{
    var builder = new Aspose.Words.DocumentBuilder(doc);
    builder.MoveToHeaderFooter(hf);
    // Insert a floating picture.
    var shape = builder.InsertImage(imageStream);
    shape.WrapType = Aspose.Words.Drawing.WrapType.None;
    shape.BehindText = false;
    shape.RelativeHorizontalPosition = Aspose.Words.Drawing.RelativeHorizontalPosition.Page;
    shape.RelativeVerticalPosition = Aspose.Words.Drawing.RelativeVerticalPosition.Page;
    // Calculate image left and top position so it appears in the centre of the page.
    shape.Left = (builder.PageSetup.PageWidth - shape.Width) / 2;
    shape.Top = (builder.PageSetup.PageHeight - shape.Height) / 2;
}

Hope, this helps.

Best regards,