Search in sources :

Example 6 with HpsMeasure

use of org.docx4j.wml.HpsMeasure in project mdw-designer by CenturyLinkCloud.

the class DocxBuilder method createParagraph.

public P createParagraph(String text, int fontSize, boolean bold) {
    ObjectFactory factory = Context.getWmlObjectFactory();
    RPr rprDoc = factory.createRPr();
    if (fontSize != 0) {
        HpsMeasure size = new HpsMeasure();
        size.setVal(BigInteger.valueOf(fontSize * 2));
        rprDoc.setSz(size);
    }
    if (bold) {
        BooleanDefaultTrue b = new BooleanDefaultTrue();
        b.setVal(true);
        rprDoc.setB(b);
    }
    P pDoc = getMdp().createParagraphOfText(text);
    R rDoc = (R) pDoc.getContent().get(0);
    rDoc.setRPr(rprDoc);
    return pDoc;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) ObjectFactory(org.docx4j.wml.ObjectFactory) RPr(org.docx4j.wml.RPr) HpsMeasure(org.docx4j.wml.HpsMeasure) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 7 with HpsMeasure

use of org.docx4j.wml.HpsMeasure in project Java-Tutorial by gpcodervn.

the class Docx4jUtils method setFontSize.

private void setFontSize(RPr runProperties, String fontSize) {
    if (fontSize != null && !fontSize.isEmpty()) {
        HpsMeasure size = new HpsMeasure();
        size.setVal(new BigInteger(fontSize));
        runProperties.setSz(size);
        runProperties.setSzCs(size);
    }
}
Also used : HpsMeasure(org.docx4j.wml.HpsMeasure) BigInteger(java.math.BigInteger)

Example 8 with HpsMeasure

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

the class Docx4J_简单例子 method getRPr.

/**
 * 创建字体
 *
 * @param isBlod
 *            粗体
 * @param isUnderLine
 *            下划线
 * @param isItalic
 *            斜体
 * @param isStrike
 *            删除线
 */
public RPr getRPr(ObjectFactory factory, String fontFamily, String colorVal, String fontSize, STHint sTHint, boolean isBlod, boolean isUnderLine, boolean isItalic, boolean isStrike) {
    RPr rPr = factory.createRPr();
    RFonts rf = new RFonts();
    rf.setHint(sTHint);
    rf.setAscii(fontFamily);
    rf.setHAnsi(fontFamily);
    rPr.setRFonts(rf);
    BooleanDefaultTrue bdt = factory.createBooleanDefaultTrue();
    rPr.setBCs(bdt);
    if (isBlod) {
        rPr.setB(bdt);
    }
    if (isItalic) {
        rPr.setI(bdt);
    }
    if (isStrike) {
        rPr.setStrike(bdt);
    }
    if (isUnderLine) {
        U underline = new U();
        underline.setVal(UnderlineEnumeration.SINGLE);
        rPr.setU(underline);
    }
    Color color = new Color();
    color.setVal(colorVal);
    rPr.setColor(color);
    HpsMeasure sz = new HpsMeasure();
    sz.setVal(new BigInteger(fontSize));
    rPr.setSz(sz);
    rPr.setSzCs(sz);
    return rPr;
}
Also used : 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) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 9 with HpsMeasure

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

the class Docx4J_简单例子2 method getRPr.

/**
 * 创建字体
 *
 * @param isBlod
 *            粗体
 * @param isUnderLine
 *            下划线
 * @param isItalic
 *            斜体
 * @param isStrike
 *            删除线
 */
public RPr getRPr(ObjectFactory factory, String fontFamily, String colorVal, String fontSize, STHint sTHint, boolean isBlod, boolean isUnderLine, boolean isItalic, boolean isStrike) {
    RPr rPr = factory.createRPr();
    RFonts rf = new RFonts();
    rf.setHint(sTHint);
    rf.setAscii(fontFamily);
    rf.setHAnsi(fontFamily);
    rPr.setRFonts(rf);
    BooleanDefaultTrue bdt = factory.createBooleanDefaultTrue();
    rPr.setBCs(bdt);
    if (isBlod) {
        rPr.setB(bdt);
    }
    if (isItalic) {
        rPr.setI(bdt);
    }
    if (isStrike) {
        rPr.setStrike(bdt);
    }
    if (isUnderLine) {
        U underline = new U();
        underline.setVal(UnderlineEnumeration.SINGLE);
        rPr.setU(underline);
    }
    Color color = new Color();
    color.setVal(colorVal);
    rPr.setColor(color);
    HpsMeasure sz = new HpsMeasure();
    sz.setVal(new BigInteger(fontSize));
    rPr.setSz(sz);
    rPr.setSzCs(sz);
    return rPr;
}
Also used : 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) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 10 with HpsMeasure

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

the class WordprocessingMLPackageRender method setFontSize.

/**
 *  本方法为可运行块添加字体大小信息. 首先创建一个"半点"尺码对象, 然后设置fontSize
 *  参数作为该对象的值, 最后我们分别设置sz和szCs的字体大小.
 *  Finally we'll set the non-complex and complex script font sizes, sz and szCs respectively.
 */
public void setFontSize(RPr runProperties, String fontSize) {
    HpsMeasure size = new HpsMeasure();
    size.setVal(new BigInteger(fontSize));
    runProperties.setSz(size);
    runProperties.setSzCs(size);
}
Also used : HpsMeasure(org.docx4j.wml.HpsMeasure) BigInteger(java.math.BigInteger)

Aggregations

HpsMeasure (org.docx4j.wml.HpsMeasure)11 BigInteger (java.math.BigInteger)9 BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)5 RPr (org.docx4j.wml.RPr)5 Color (org.docx4j.wml.Color)4 RFonts (org.docx4j.wml.RFonts)4 U (org.docx4j.wml.U)4 CTShd (org.docx4j.wml.CTShd)1 CTSignedHpsMeasure (org.docx4j.wml.CTSignedHpsMeasure)1 Highlight (org.docx4j.wml.Highlight)1 ObjectFactory (org.docx4j.wml.ObjectFactory)1 P (org.docx4j.wml.P)1 ParaRPr (org.docx4j.wml.ParaRPr)1 R (org.docx4j.wml.R)1