在文本框中更改字体大小-Apache POI Word DOCX [英] Change font size in text box - apache poi word docx
本文介绍了在文本框中更改字体大小-Apache POI Word DOCX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了答案,该答案解释了如何在docx文档中插入新的文本框.
I found the answer that explains how to insert a new text box into docx document.
问题是我无法在新创建的文本框中更改字体大小.
The problem is that I cannot change the font size inside a newly created text box.
有人知道怎么做吗?
推荐答案
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);
...
这篇关于在文本框中更改字体大小-Apache POI Word DOCX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文