Free Support Forum - aspose.com

HeaderFooterType.Footer[Anything] writes to the header instead

I’m trying to insert an image into the footer following this example and no matter what I try (.FooterFirst or .FooterEven), the image always ends up in the header:


DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

string imageFileName = “test.jpg”;
builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 20.5, RelativeVerticalPosition.Page, 25.5, 40, 50, WrapType.None);

I even tried this in a fresh document and the image still ends up in the header. I can also tell that it’s being added to the header (and not the footer but with a large offset) because the rest of my header gets shifted down with WrapType.Inline, for example, and the footer stays unaffected).

The version of the Aspose.Words.dll that I’m using is 15.5.0.0.

Is this a bug?

Hi Rainier,

Relative positions are changing the position of the image. You can use the following InsertImage overload to keep the image inside the footer

builder.InsertImage(imageFileName);

or change the relative positions e.g.

builder.InsertImage(imageFileName, RelativeHorizontalPosition.Character, 10, RelativeVerticalPosition.Paragraph, 10, 50, 50, WrapType.Through);

Best Regards,