Search in sources :

Example 11 with RPr

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

Example 12 with RPr

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

Example 13 with 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);
}
Also used : RPr(org.docx4j.wml.RPr)

Example 14 with 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;
}
Also used : Text(org.docx4j.wml.Text) P(org.docx4j.wml.P) CTLanguage(org.docx4j.wml.CTLanguage) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) U(org.docx4j.wml.U) RPr(org.docx4j.wml.RPr) ParaRPr(org.docx4j.wml.ParaRPr) ParaRPr(org.docx4j.wml.ParaRPr) Jc(org.docx4j.wml.Jc)

Example 15 with RPr

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

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