Search in sources :

Example 26 with P

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;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) Ftr(org.docx4j.wml.Ftr) RPr(org.docx4j.wml.RPr)

Example 27 with P

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;
}
Also used : P(org.docx4j.wml.P) PPr(org.docx4j.wml.PPr) Jc(org.docx4j.wml.Jc)

Example 28 with 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);
}
Also used : P(org.docx4j.wml.P) RPr(org.docx4j.wml.RPr) Comments(org.docx4j.wml.Comments) BigInteger(java.math.BigInteger)

Example 29 with P

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;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) Comments(org.docx4j.wml.Comments) Comment(org.docx4j.wml.Comments.Comment) Text(org.docx4j.wml.Text)

Example 30 with P

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;
}
Also used : P(org.docx4j.wml.P) ArrayList(java.util.ArrayList)

Aggregations

P (org.docx4j.wml.P)101 R (org.docx4j.wml.R)58 Text (org.docx4j.wml.Text)32 Test (org.junit.Test)23 PPr (org.docx4j.wml.PPr)22 RPr (org.docx4j.wml.RPr)21 ObjectFactory (org.docx4j.wml.ObjectFactory)18 Jc (org.docx4j.wml.Jc)16 BigInteger (java.math.BigInteger)14 CTVerticalJc (org.docx4j.wml.CTVerticalJc)14 Drawing (org.docx4j.wml.Drawing)14 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)13 STVerticalJc (org.docx4j.wml.STVerticalJc)11 Tc (org.docx4j.wml.Tc)11 File (java.io.File)10 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)10 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)10 Tbl (org.docx4j.wml.Tbl)10 Tr (org.docx4j.wml.Tr)10 Br (org.docx4j.wml.Br)9