use of org.docx4j.wml.RPr in project docx4j-template by vindell.
the class TableWithStyledContent method addStyling.
/**
* 这里我们添加实际的样式信息, 首先创建一个段落, 然后创建以单元格内容作为值的文本对象;
* 第三步, 创建一个被称为运行块的对象, 它是一块或多块拥有共同属性的文本的容器, 并将文本对象添加
* 到其中. 随后我们将运行块R添加到段落内容中.
* 直到现在我们所做的还没有添加任何样式, 为了达到目标, 我们创建运行块属性对象并给它添加各种样式.
* 这些运行块的属性随后被添加到运行块. 最后段落被添加到表格的单元格中.
*/
private static void addStyling(Tc tableCell, String content, boolean bold, String fontSize) {
P paragraph = factory.createP();
Text text = factory.createText();
text.setValue(content);
R run = factory.createR();
run.getContent().add(text);
paragraph.getContent().add(run);
RPr runProperties = factory.createRPr();
if (bold) {
addBoldStyle(runProperties);
}
if (fontSize != null && !fontSize.isEmpty()) {
setFontSize(runProperties, fontSize);
}
run.setRPr(runProperties);
tableCell.getContent().add(paragraph);
}
use of org.docx4j.wml.RPr in project docx4j-template by vindell.
the class ChangingTheStyleSheet method getRunPropertiesAndRemoveThemeInfo.
private static RPr getRunPropertiesAndRemoveThemeInfo(Style style) {
// We only want to change some settings, so we get the existing run
// properties from the style.
RPr rpr = style.getRPr();
removeThemeFontInformation(rpr);
return rpr;
}
use of org.docx4j.wml.RPr in project docx4j-template by vindell.
the class ChangingTheStyleSheet method alterHeading2Style.
/**
* For this style, we get the existing run properties from the style and
* remove the theme font information from them. Then we also remove the bold
* styling, change the font size (half-points) and add an underline.
*/
private static void alterHeading2Style(Style style) {
RPr rpr = getRunPropertiesAndRemoveThemeInfo(style);
removeBoldStyle(rpr);
changeFontSize(rpr, 24);
addUnderline(rpr);
}
use of org.docx4j.wml.RPr in project TranskribusCore by Transkribus.
the class DocxBuilder method createIt.
public static P createIt() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
P p = wmlObjectFactory.createP();
// Create object for pPr
PPr ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
// Create object for rPr
ParaRPr pararpr = wmlObjectFactory.createParaRPr();
ppr.setRPr(pararpr);
// Create object for u
U u = wmlObjectFactory.createU();
pararpr.setU(u);
u.setVal(org.docx4j.wml.UnderlineEnumeration.SINGLE);
// Create object for lang
CTLanguage language = wmlObjectFactory.createCTLanguage();
pararpr.setLang(language);
language.setVal("en-AU");
// Create object for jc
Jc jc = wmlObjectFactory.createJc();
ppr.setJc(jc);
jc.setVal(org.docx4j.wml.JcEnumeration.CENTER);
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add(r);
// Create object for rPr
RPr rpr = wmlObjectFactory.createRPr();
r.setRPr(rpr);
// Create object for u
U u2 = wmlObjectFactory.createU();
rpr.setU(u2);
u2.setVal(org.docx4j.wml.UnderlineEnumeration.SINGLE);
// Create object for lang
CTLanguage language2 = wmlObjectFactory.createCTLanguage();
rpr.setLang(language2);
language2.setVal("en-AU");
// Create object for t (wrapped in JAXBElement)
Text text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
r.getContent().add(textWrapped);
text.setValue("Underlined and centred");
return p;
}
use of org.docx4j.wml.RPr in project mdw-designer by CenturyLinkCloud.
the class DocxBuilder method createBoldParagraph.
public P createBoldParagraph(String style, String text) {
ObjectFactory factory = Context.getWmlObjectFactory();
RPr rprDoc = factory.createRPr();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
rprDoc.setB(b);
P pDoc = getMdp().createStyledParagraphOfText(style, text);
R rDoc = (R) pDoc.getContent().get(0);
rDoc.setRPr(rprDoc);
return pDoc;
}
Aggregations