use of org.docx4j.wml.P in project docx4j-template by vindell.
the class Docx4J_简单例子2 method createFooterWithPageNr.
public Ftr createFooterWithPageNr(ObjectFactory factory) {
Ftr ftr = factory.createFtr();
P paragraph = factory.createP();
RPr fontRPr = getRPr(factory, "宋体", "000000", "20", STHint.EAST_ASIA, false, false, false, false);
R run = factory.createR();
run.setRPr(fontRPr);
paragraph.getContent().add(run);
addPageTextField(factory, paragraph, "第");
addFieldBegin(factory, paragraph);
addPageNumberField(factory, paragraph);
addFieldEnd(factory, paragraph);
addPageTextField(factory, paragraph, "页");
addPageTextField(factory, paragraph, " 总共");
addFieldBegin(factory, paragraph);
addTotalPageNumberField(factory, paragraph);
addFieldEnd(factory, paragraph);
addPageTextField(factory, paragraph, "页");
setParagraphAlign(factory, paragraph, JcEnumeration.CENTER);
ftr.getContent().add(paragraph);
return ftr;
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class Docx4j_Helper method createParagraphWithHAlign.
/**
* 创建段落设置水平对齐方式
* @return
*/
private P createParagraphWithHAlign() {
P p;
PPr pPr;
p = Docx4j_Helper.factory.createP();
pPr = Docx4j_Helper.factory.createPPr();
Jc jc = Docx4j_Helper.factory.createJc();
jc.setVal(JcEnumeration.CENTER);
pPr.setJc(jc);
p.setPPr(pPr);
return p;
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class Docx4j_创建批注_S3_Test method testCreateComment.
public void testCreateComment(WordprocessingMLPackage wordMLPackage, MainDocumentPart t, ObjectFactory factory) throws Exception {
P p = factory.createP();
setParagraphSpacing(factory, p, true, "0", "0", true, null, "100", true, "240", STLineSpacingRule.AUTO);
t.addObject(p);
RPr fontRPr = getRPrStyle(factory, "微软雅黑", "000000", "20", STHint.EAST_ASIA, false, false, false, true, UnderlineEnumeration.SINGLE, "B61CD2", true, "darkYellow", false, null, null, null);
RPr commentRPr = getRPrStyle(factory, "微软雅黑", "41A62D", "18", STHint.EAST_ASIA, true, true, false, false, null, null, false, null, false, null, null, null);
Comments comments = addDocumentCommentsPart(wordMLPackage, factory);
BigInteger commentId = BigInteger.valueOf(1);
createCommentEnd(factory, p, "测试", "这是官网Demo", fontRPr, commentRPr, commentId, comments);
commentId = commentId.add(BigInteger.ONE);
createCommentRound(factory, p, "批注", "这是批注comment", fontRPr, commentRPr, commentId, comments);
commentId = commentId.add(BigInteger.ONE);
p = factory.createP();
setParagraphSpacing(factory, p, true, "0", "0", true, null, "100", true, "240", STLineSpacingRule.AUTO);
t.addObject(p);
createCommentRound(factory, p, "批注2", "这是批注comment2", fontRPr, commentRPr, commentId, comments);
commentId = commentId.add(BigInteger.ONE);
createCommentEnd(factory, p, "测试2", "这是官网Demo", fontRPr, commentRPr, commentId, comments);
commentId = commentId.add(BigInteger.ONE);
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class Docx4j_创建批注_S3_Test method createComment.
public Comments.Comment createComment(ObjectFactory factory, BigInteger commentId, String author, Date date, String commentContent, RPr commentRPr) throws Exception {
Comments.Comment comment = factory.createCommentsComment();
comment.setId(commentId);
if (author != null) {
comment.setAuthor(author);
}
if (date != null) {
comment.setDate(toXMLCalendar(date));
}
P commentP = factory.createP();
comment.getEGBlockLevelElts().add(commentP);
R commentR = factory.createR();
commentP.getContent().add(commentR);
Text commentText = factory.createText();
commentR.getContent().add(commentText);
commentR.setRPr(commentRPr);
commentText.setValue(commentContent);
return comment;
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method getTcAllP.
public List<P> getTcAllP(Tc tc) {
List<Object> objList = getAllElementFromObject(tc, P.class);
List<P> pList = new ArrayList<P>();
if (objList == null) {
return pList;
}
for (Object obj : objList) {
if (obj instanceof P) {
P p = (P) obj;
pList.add(p);
}
}
return pList;
}
Aggregations