Search in sources :

Example 11 with BooleanDefaultTrue

use of org.docx4j.wml.BooleanDefaultTrue 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)

Example 12 with BooleanDefaultTrue

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

the class DocxBuilder method addBoldParagraph.

public P addBoldParagraph(String text) {
    ObjectFactory factory = Context.getWmlObjectFactory();
    RPr rprDoc = factory.createRPr();
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    rprDoc.setB(b);
    P pDoc = getMdp().addParagraphOfText(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)

Example 13 with BooleanDefaultTrue

use of org.docx4j.wml.BooleanDefaultTrue 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 14 with BooleanDefaultTrue

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

the class Docx4jUtils method setCellNoWrap.

private void setCellNoWrap(Tc tableCell) {
    TcPr tableCellProperties = tableCell.getTcPr();
    if (tableCellProperties == null) {
        tableCellProperties = new TcPr();
        tableCell.setTcPr(tableCellProperties);
    }
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    tableCellProperties.setNoWrap(b);
}
Also used : TcPr(org.docx4j.wml.TcPr) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 15 with BooleanDefaultTrue

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

the class Write_Format method main.

public static void main(String[] args) throws Docx4JException {
    WordprocessingMLPackage wordPackage = WordprocessingMLPackage.createPackage();
    MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
    mainDocumentPart.addStyledParagraphOfText("Title", "Hello World!");
    mainDocumentPart.addParagraphOfText("Welcome To Baeldung");
    ObjectFactory factory = Context.getWmlObjectFactory();
    P p = factory.createP();
    R r = factory.createR();
    Text t = factory.createText();
    t.setValue("Welcome To Baeldung");
    r.getContent().add(t);
    p.getContent().add(r);
    RPr rpr = factory.createRPr();
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    rpr.setB(b);
    rpr.setI(b);
    rpr.setCaps(b);
    Color green = factory.createColor();
    green.setVal("green");
    rpr.setColor(green);
    r.setRPr(rpr);
    mainDocumentPart.getContent().add(p);
    File exportFile = new File("output/welcome2.docx");
    wordPackage.save(exportFile);
    System.out.println("Done!");
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) ObjectFactory(org.docx4j.wml.ObjectFactory) RPr(org.docx4j.wml.RPr) MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart) Color(org.docx4j.wml.Color) Text(org.docx4j.wml.Text) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue) WordprocessingMLPackage(org.docx4j.openpackaging.packages.WordprocessingMLPackage) File(java.io.File)

Aggregations

BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)28 RPr (org.docx4j.wml.RPr)9 Color (org.docx4j.wml.Color)6 HpsMeasure (org.docx4j.wml.HpsMeasure)5 ObjectFactory (org.docx4j.wml.ObjectFactory)5 P (org.docx4j.wml.P)5 R (org.docx4j.wml.R)5 BigInteger (java.math.BigInteger)4 RFonts (org.docx4j.wml.RFonts)4 U (org.docx4j.wml.U)4 File (java.io.File)2 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)2 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)2 ParaRPr (org.docx4j.wml.ParaRPr)2 TcPr (org.docx4j.wml.TcPr)2 Text (org.docx4j.wml.Text)2 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)1 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)1 CTShd (org.docx4j.wml.CTShd)1 Highlight (org.docx4j.wml.Highlight)1