I am writing a Word document and want to place an image in the header which I want to be centered. I am using the following code and the image is placed in the header but is left justified not centered. How can I center the image?
// Write the header image to the header
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.getFont().setName("Arial");
builder.getFont().setSize(11.0);
String imageFileName = headerImage.getPath();
Shape shape = builder.insertImage(imageFileName);
shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setHorizontalAlignment(HorizontalAlignment.CENTER);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
shape.setVerticalAlignment(VerticalAlignment.CENTER);