use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4J_例子2 method addPageBreak.
// 分页
public void addPageBreak(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, STBrType sTBrType) {
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
Br breakObj = new Br();
breakObj.setType(sTBrType);
P paragraph = factory.createP();
paragraph.getContent().add(breakObj);
documentPart.addObject(paragraph);
}
use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4J_简单例子2 method addPageBreak.
// 分页
public void addPageBreak(WordprocessingMLPackage wordMLPackage, ObjectFactory factory) {
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
Br breakObj = new Br();
breakObj.setType(STBrType.PAGE);
P paragraph = factory.createP();
paragraph.getContent().add(breakObj);
documentPart.addObject(paragraph);
}
use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method addPageBreak.
/**
* @Description: 段落添加Br 页面Break(分页符)
*/
public void addPageBreak(P para, STBrType sTBrType) {
Br breakObj = new Br();
breakObj.setType(sTBrType);
para.getContent().add(breakObj);
}
use of org.docx4j.wml.Br in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setParaRContent.
/**
* @Description: 设置段落内容
*/
public void setParaRContent(P p, RPr runProperties, String content) {
R run = null;
List<Object> rList = p.getContent();
if (rList != null && rList.size() > 0) {
for (int i = 0, len = rList.size(); i < len; i++) {
// 清除内容(所有的r
p.getContent().remove(0);
}
}
run = new R();
p.getContent().add(run);
if (content != null) {
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 AddingPageNrToFooter method addPageBreak.
/**
* Adds a page break to the document.
*
* @param documentPart
*/
private static void addPageBreak(MainDocumentPart documentPart) {
Br breakObj = new Br();
breakObj.setType(STBrType.PAGE);
P paragraph = factory.createP();
paragraph.getContent().add(breakObj);
documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
Aggregations