Insert image on top of other image

Hi,
I am using documentbuilder.insertimage to add an image to word document at particular location. But the image is going to the background of the existing image. How can I make it to overwrite the existing image and come to the foreground.
Here is my code

DocumentBuilder b = new DocumentBuilder(doc);
b.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
b.insertImage(createByteImage(), RelativeHorizontalPosition.PAGE, 420, RelativeVerticalPosition.PAGE, 25, 150, 50,WrapType.NONE);

This very important and urgent. Please help
Sri

This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your inquiry. Could you please attach your input document and image here for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi Andrey Noskov,

Thanks for your reply. I looked at the below thread and able to delete the existing image from the header and then add the new image. Looks like this solution would work for us.
Insert Image on the header in the word doc

I changed the code to:

HeaderFooterCollection headersFooters = doc.getFirstSection().getHeadersFooters();
HeaderFooter header = headersFooters.getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);

NodeCollection shapes = header.getChildNodes(NodeType.SHAPE, true);
shapes.clear();
DocumentBuilder b = new DocumentBuilder(doc);
b.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
b.insertImage(createByteImage(), RelativeHorizontalPosition.PAGE, 420, RelativeVerticalPosition.PAGE, 25, 150, 50,WrapType.NONE);

Let me know if there is a better way of handling this.

Thanks,
Sri

Hi Sri,

It is perfect, that you already found the way to resolve the problem. Your code looks correct.
Best regards,