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;
}
use of org.docx4j.wml.HpsMeasure 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;
}
use of org.docx4j.wml.HpsMeasure in project docx4j-template by vindell.
the class Docx4jStyle_S3 method setFontSize.
public 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);
}
}
use of org.docx4j.wml.HpsMeasure in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setFontSize.
/**
* @Description: 设置字体大小
*/
public void setFontSize(RPr runProperties, String fontSize) {
if (StringUtils.isNotBlank(fontSize)) {
HpsMeasure size = new HpsMeasure();
size.setVal(new BigInteger(fontSize));
runProperties.setSz(size);
runProperties.setSzCs(size);
}
}
use of org.docx4j.wml.HpsMeasure in project docx4j-template by vindell.
the class TableWithStyledContent method setFontSize.
/**
* 本方法为可运行块添加字体大小信息. 首先创建一个"半点"尺码对象, 然后设置fontSize
* 参数作为该对象的值, 最后我们分别设置sz和szCs的字体大小.
* Finally we'll set the non-complex and complex script font sizes, sz and szCs respectively.
*/
private static void setFontSize(RPr runProperties, String fontSize) {
HpsMeasure size = new HpsMeasure();
size.setVal(new BigInteger(fontSize));
runProperties.setSz(size);
runProperties.setSzCs(size);
}
Aggregations