Does someone knows what is the meaning and unit of x
and y
in Office Open XML wrapPolygon
?
The documentation states:
"Specifies a coordinate on the x-axis. The origin point for this coordinate shall be specified by the parent XML element. ...The possible values for this attribute are defined by the ST_Coordinate simple type (§ 5.1.12.16)."
That sounds like it should be describing a polygon starting at x
=0 and y
=0 in top left point of the picture. And the unit would be EMU
.
But this cannot be true because if used in the code Change image layout or wrap in DOCX with Apache POI, then, if I do something like:
...
+"<wp:wrapTight wrapText=\"bothSides\">"
+"<wp:wrapPolygon edited=\"0\">"
+"<wp:start x=\"0\" y=\"0\"/>"
+"<wp:lineTo x=\"0\" y=\""+height+"\"/>"
+"<wp:lineTo x=\""+width+"\" y=\""+height+"\"/>"
+"<wp:lineTo x=\""+width+"\" y=\"0\"/>"
+"<wp:lineTo x=\"0\" y=\"0\"/>"
+"</wp:wrapPolygon>"
+"</wp:wrapTight>"
...
then the resulting wrap points are much far outside the picture.
Instead describing a square polygon 21600 x 21600
...
+"<wp:wrapPolygon edited=\"0\">"
+"<wp:start x=\"0\" y=\"0\"/>"
+"<wp:lineTo x=\"0\" y=\"21600\"/>"
+"<wp:lineTo x=\"21600\" y=\"21600\"/>"
+"<wp:lineTo x=\"21600\" y=\"0\"/>"
+"<wp:lineTo x=\"0\" y=\"0\"/>"
+"</wp:wrapPolygon>"
...
leads to wrap points which are in fully width x height of the picture.
And this is independent of the pictures size itself. It may be a square or rectangle sized picture in all possible sizes.
So while "The origin point for this coordinate shall be specified by the parent XML element." and the polygon starts at x
=0 and y
=0 in top left point of the picture, the unit cannot be EMU
as for width and height. And since a square polygon 21600 x 21600 leads to rectangle wrap points if the picture is a rectangle, even the meaning of the polygon itself is not clear.
Is this documented somewhere?
Well, seems nobody answers. So I will at least providing an example for why this rule: "A square polygon 21600 x 21600 leads to wrap points in fully width x height independent of picture size." could be useful.
If the need is setting more complex wrap points, a ellipse for example, only depicting this ellipse to a square 21600 x 21600 is needed, independent of picture size. This is much more simple than calculating the wrap points dependent on the really picture size. So we can forcing
Word
having really wrapping text tight around the picture.Example Code:
Result: