Problem with Footer when adding image (Aspose.Words)

Hi all. I need help, i hope, someone can help me.

Problem:
I use Aspose.Words and try add aligned image in header and footer using-
public Aspose.Words.Drawing.Shape InsertImage ( Byte[] imageBytes, RelativeHorizontalPosition horzPos, Double left, RelativeVerticalPosition vertPos, Double top, Double width, Double height, WrapType wrapType )

My code:

InsertImage(image_Bytes,
    Aspose.Words.Drawing.RelativeHorizontalPosition.LeftMargin, 
    (row_Cell_Width - image_Width) / 2, //horisontal align
    Aspose.Words.Drawing.RelativeVerticalPosition.Margin, 
    (row_Height - image_Height) / 2, //vertical align
    image_Width, 
    image_Height, 
    Aspose.Words.Drawing.WrapType.None);

Result : Header\Footer (see attachment)

Please tell me, why in the footer images so moved out and the header are displayed in the right place. I do not know what to do. Сan be a problem in RelativeVerticalPosition?

Thanks!!!

Hi,

Thanks for your inquiry. Could you please attach your input Word document along with image here for testing? I will investigate the issue on my side and provide you more information.

See attachment.

thank you in advance!

Hi Sviatoslav,

Thanks for sharing the document. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.1.0) from here.

Please note that Aspose.Words tries to mimic the same behavior as MS Word do. The images in your document have text wrapping “in Font of Text”. If you change the text wrapping manually by using MS Word, you will see the exact behavior of MS Word. Please see the attached image.

In your case, I suggest you please use the text wrapping as “inline” for footer images as shown in following code snippet.

Document doc = new Document(MyDir + "in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);
Table table = (Table) doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChild(NodeType.Table, 0, true);
byte[] image = File.ReadAllBytes(MyDir + "Aspose.jpg");
builder.MoveTo(table.FirstRow.Cells[0].FirstParagraph);
builder.InsertImage(image, RelativeHorizontalPosition.LeftMargin, 0, RelativeVerticalPosition.Margin, 0, 80, 20, WrapType.Inline);
doc.Save(MyDir + "out.doc");

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Thanks for helping!!!

Hi Sviatoslav,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.