Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2019);
docBuilder.write("hello123");
docBuilder.write("hello123");
Shape imageShapeObj1 = docBuilder.insertImage("test123.jpeg",100.0,100.0);
imageShapeObj1.setRelativeHorizontalPosition(RelativeHorizontalPosition.MARGIN);
imageShapeObj1.setRelativeVerticalPosition(RelativeVerticalPosition.LINE);
imageShapeObj1.setWrapType(WrapType.SQUARE);
imageShapeObj1.setWrapSide(WrapSide.BOTH);
imageShapeObj1.setHorizontalAlignment(HorizontalAlignment.LEFT);
docBuilder.write("hello123");
docBuilder.write("hello123");
//What Break or any other way to achieve the expected result
docBuilder.insertBreak(BreakType.PAGE_BREAK);
docBuilder.write("hello123");
docBuilder.write("hello123");
Shape imageShapeObj2 = docBuilder.insertImage("test123.jpeg",100.0,100.0);
imageShapeObj2.setRelativeHorizontalPosition(RelativeHorizontalPosition.MARGIN);
imageShapeObj2.setRelativeVerticalPosition(RelativeVerticalPosition.LINE);
imageShapeObj2.setWrapType(WrapType.SQUARE);
imageShapeObj2.setWrapSide(WrapSide.BOTH);
imageShapeObj2.setHorizontalAlignment(HorizontalAlignment.RIGHT);
docBuilder.write("hello123");
docBuilder.write("hello123");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save("Test.docx",saveOptions);
Above is my code , My issue is the output of the code is this.
I want the output like this
TLDR : I want the a break or any solution such that it next content are after the floated image
How do i achieve the expected output ?