npoi-examples
npoi-examples copied to clipboard
How to set picture layout type in XWPF?
Hi i would like to know how i can set the picture layout type after adding it with addPicture(). Thanks.
What does 'picture layout type' exactly mean?
What does 'picture layout type' exactly mean?
Hi i want the set the anchor of the picture to wrapSquare. Something like what they did here: https://stackoverflow.com/questions/47673133/change-image-layout-or-wrap-in-docx-with-apache-poi
But i want to achieve something like this:
I want to create a column of pictures where each is separated by some text. Pictures must be one after the other without overlapping or being in the same row. Each picture must have a Square layout. All pictures have the same size.
Inline open xml in document.xml
<wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="64379659" wp14:editId="59692A46">
<wp:extent cx="5267325" cy="3867150"/>
<wp:effectExtent l="0" t="0" r="9525" b="0"/>
Text Wrapping - Square
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="64379659" wp14:editId="5AEE703F">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:posOffset>0</wp:posOffset>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>47625</wp:posOffset>
</wp:positionV>
<wp:extent cx="5267325" cy="3867150"/>
<wp:effectExtent l="0" t="0" r="9525" b="0"/>
<wp:wrapSquare wrapText="bothSides"/>
Text Wrapping - Tight
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="1" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="64379659" wp14:editId="21EC34FE">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:posOffset>0</wp:posOffset>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>47625</wp:posOffset>
</wp:positionV>
<wp:extent cx="5267325" cy="3867150"/>
<wp:effectExtent l="0" t="0" r="9525" b="0"/>
<wp:wrapTight wrapText="bothSides">
<wp:wrapPolygon edited="0">
<wp:start x="0" y="0"/>
<wp:lineTo x="0" y="21494"/>
<wp:lineTo x="21561" y="21494"/>
<wp:lineTo x="21561" y="0"/>
<wp:lineTo x="0" y="0"/>
</wp:wrapPolygon>
</wp:wrapTight>
Text Wrapping - Through
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="64379659" wp14:editId="31E731D6">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:posOffset>0</wp:posOffset>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>47625</wp:posOffset>
</wp:positionV>
<wp:extent cx="5267325" cy="3867150"/>
<wp:effectExtent l="0" t="0" r="9525" b="0"/>
<wp:wrapThrough wrapText="bothSides">
<wp:wrapPolygon edited="0">
<wp:start x="0" y="0"/>
<wp:lineTo x="0" y="21494"/>
<wp:lineTo x="21561" y="21494"/>
<wp:lineTo x="21561" y="0"/>
<wp:lineTo x="0" y="0"/>
</wp:wrapPolygon>
</wp:wrapThrough>
Openxml document about Wrapping - http://officeopenxml.com/drwPicFloating-textWrap.php
The major difficulty here is how to calculate WrapPolygon coordinates
https://stackoverflow.com/questions/7213133/openxml-and-word-how-to-calculate-wrappolygon-coordinates
Hi, thank you for your solution I will test it out as soon as possible. This might also help others facing the same problem.