Reference : create text box in document .docx using apache poi
The ctTxbxContent.addNewP()
in my code creates a CTP
object. The XWPFParagraph
has a constructor XWPFParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP prgrph, IBody part)
. So you can get a XWPFParagraph
from the CTP
object and then use the default apache-poi
methods further.
...
CTTxbxContent ctTxbxContent = ctShape.addNewTextbox().addNewTxbxContent();
XWPFParagraph textboxparagraph = new XWPFParagraph(ctTxbxContent.addNewP(), (IBody)doc);
XWPFRun textboxrun = textboxparagraph.createRun();
textboxrun.setText("The TextBox text...");
textboxrun.setFontSize(24);
...