我有一段文字,我想在文件的中心出现.我怎么能在docx4j中这样做?我目前正在使用:
PPr paragraphProperties = factory.createPPr();
//creating the alignment
TextAlignment align = new TextAlignment();
align.setVal("center");
paragraphProperties.setTextAlignment(align);
//centering the paragraph
paragraph.setPPr(paragraphProperties);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
你快到了.而不是TextAlignment使用对象设置它,而是使用Jc实例(对齐):
PPr paragraphProperties = factory.createPPr();
Jc justification = factory.createJc();
justification.setVal(JcEnumeration.CENTER);
paragraphProperties.setJc(justification);
Run Code Online (Sandbox Code Playgroud)
一种简单的方法来解决这个问题:
document.xml其中提取文件| 归档时间: |
|
| 查看次数: |
2969 次 |
| 最近记录: |