Search in sources :

Example 6 with RPr

use of org.docx4j.wml.RPr in project docx4j-template by vindell.

the class Docx4J_简单例子 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 7 with RPr

use of org.docx4j.wml.RPr 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 8 with RPr

use of org.docx4j.wml.RPr 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 9 with RPr

use of org.docx4j.wml.RPr in project docx4j-template by vindell.

the class Docx4j_创建批注_S3_Test method getRPrStyle.

// 字体样式
public RPr getRPrStyle(ObjectFactory factory, String fontFamily, String colorVal, String fontSize, STHint sTHint, boolean isBlod, boolean isItalic, boolean isStrike, boolean isUnderLine, UnderlineEnumeration underLineStyle, String underLineColor, boolean isHightLight, String hightLightValue, boolean isShd, STShd shdValue, String shdColor, CTVerticalAlignRun stRunEnum) {
    RPr rPr = factory.createRPr();
    RFonts rf = new RFonts();
    if (sTHint != null) {
        rf.setHint(sTHint);
    }
    if (fontFamily != null) {
        rf.setAscii(fontFamily);
        rf.setEastAsia(fontFamily);
        rf.setHAnsi(fontFamily);
    }
    rPr.setRFonts(rf);
    if (colorVal != null) {
        Color color = new Color();
        color.setVal(colorVal);
        rPr.setColor(color);
    }
    if (fontSize != null) {
        HpsMeasure sz = new HpsMeasure();
        sz.setVal(new BigInteger(fontSize));
        rPr.setSz(sz);
        rPr.setSzCs(sz);
    }
    BooleanDefaultTrue bdt = factory.createBooleanDefaultTrue();
    if (isBlod) {
        rPr.setB(bdt);
    }
    if (isItalic) {
        rPr.setI(bdt);
    }
    if (isStrike) {
        rPr.setStrike(bdt);
    }
    if (isUnderLine) {
        U underline = new U();
        if (underLineStyle != null) {
            underline.setVal(underLineStyle);
        }
        if (underLineColor != null) {
            underline.setColor(underLineColor);
        }
        rPr.setU(underline);
    }
    if (isHightLight) {
        Highlight hight = new Highlight();
        hight.setVal(hightLightValue);
        rPr.setHighlight(hight);
    }
    if (isShd) {
        CTShd shd = new CTShd();
        if (shdColor != null) {
            shd.setColor(shdColor);
        }
        if (shdValue != null) {
            shd.setVal(shdValue);
        }
        rPr.setShd(shd);
    }
    if (stRunEnum != null) {
        rPr.setVertAlign(stRunEnum);
    }
    return rPr;
}
Also used : Highlight(org.docx4j.wml.Highlight) RPr(org.docx4j.wml.RPr) U(org.docx4j.wml.U) HpsMeasure(org.docx4j.wml.HpsMeasure) Color(org.docx4j.wml.Color) RFonts(org.docx4j.wml.RFonts) BigInteger(java.math.BigInteger) CTShd(org.docx4j.wml.CTShd) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 10 with RPr

use of org.docx4j.wml.RPr in project docx4j-template by vindell.

the class Docx4j_工具类_S3_Test method getRPr.

public RPr getRPr(R r) {
    RPr rpr = r.getRPr();
    if (rpr == null) {
        rpr = new RPr();
        r.setRPr(rpr);
    }
    return rpr;
}
Also used : RPr(org.docx4j.wml.RPr) ParaRPr(org.docx4j.wml.ParaRPr)

Aggregations

RPr (org.docx4j.wml.RPr)37 P (org.docx4j.wml.P)21 R (org.docx4j.wml.R)19 Text (org.docx4j.wml.Text)12 BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)9 BigInteger (java.math.BigInteger)8 ParaRPr (org.docx4j.wml.ParaRPr)8 U (org.docx4j.wml.U)7 Color (org.docx4j.wml.Color)6 PPr (org.docx4j.wml.PPr)6 RFonts (org.docx4j.wml.RFonts)6 Tbl (org.docx4j.wml.Tbl)6 Tr (org.docx4j.wml.Tr)6 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)5 HpsMeasure (org.docx4j.wml.HpsMeasure)5 ObjectFactory (org.docx4j.wml.ObjectFactory)5 File (java.io.File)4 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)4 STHint (org.docx4j.wml.STHint)4 Ftr (org.docx4j.wml.Ftr)3