@merlin1234 The problem in this case occurs because there are 3 floating shapes in the same paragraph in the header and setting paragraph left margin shifts the shapes outside the page bounds. If use the following code and simply change the wrap type of the shapes, they are rendered:
Document doc = new Document("C:\\Temp\\in.docx");
Iterable<HeaderFooter> headerFooters = doc.getChildNodes(NodeType.HEADER_FOOTER, true);
for (HeaderFooter hf : headerFooters)
{
Iterable<Shape> shapes = hf.getChildNodes(NodeType.SHAPE, true);
for (Shape s : shapes)
{
if (s.isTopLevel())
{
s.setWrapType(WrapType.INLINE);
}
}
}
doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");
But position is incorrect. I am afraid there is no programmatic workaround for this case. The only way to fix this is editing your template manually in MS Word and using table to place the shapes on the different sides of the page.