use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class AddingAPageBreak method addPageBreak.
/**
* 向文档添加一个换行符
*/
private static void addPageBreak() {
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
Br breakObj = new Br();
breakObj.setType(STBrType.PAGE);
P paragraph = factory.createP();
paragraph.getContent().add(breakObj);
documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method appendParaRContent.
/**
* @Description: 添加段落内容
*/
public void appendParaRContent(P p, RPr runProperties, String content) {
if (content != null) {
R run = new R();
p.getContent().add(run);
String[] contentArr = content.split("\n");
Text text = new Text();
text.setSpace("preserve");
text.setValue(contentArr[0]);
run.setRPr(runProperties);
run.getContent().add(text);
for (int i = 1, len = contentArr.length; i < len; i++) {
Br br = new Br();
// 换行
run.getContent().add(br);
text = new Text();
text.setSpace("preserve");
text.setValue(contentArr[i]);
run.setRPr(runProperties);
run.getContent().add(text);
}
}
}
use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4j_替换模板 method setNewTcContent.
/**
* 设置单元格内容
*
* @param tc
* @param content
*/
public static void setNewTcContent(Tc tc, String content) {
P p = factory.createP();
tc.getContent().add(p);
R run = factory.createR();
p.getContent().add(run);
if (content != null) {
String[] contentArr = content.split("\n");
Text text = factory.createText();
text.setSpace("preserve");
text.setValue(contentArr[0]);
run.getContent().add(text);
for (int i = 1, len = contentArr.length; i < len; i++) {
Br br = factory.createBr();
// 换行
run.getContent().add(br);
text = factory.createText();
text.setSpace("preserve");
text.setValue(contentArr[i]);
run.getContent().add(text);
}
}
}
Aggregations