Search in sources :

Example 11 with Jc

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

the class Docx4J_简单例子2 method newImage.

public P newImage(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, Part sourcePart, byte[] bytes, String filenameHint, String altText, int id1, int id2, JcEnumeration jcEnumeration) throws Exception {
    BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, sourcePart, bytes);
    Inline inline = imagePart.createImageInline(filenameHint, altText, id1, id2, false);
    P p = factory.createP();
    R run = factory.createR();
    p.getContent().add(run);
    Drawing drawing = factory.createDrawing();
    run.getContent().add(drawing);
    drawing.getAnchorOrInline().add(inline);
    PPr pPr = p.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    p.setPPr(pPr);
    PBdr pBdr = pPr.getPBdr();
    if (pBdr == null) {
        pBdr = factory.createPPrBasePBdr();
    }
    CTBorder value = new CTBorder();
    value.setVal(STBorder.SINGLE);
    value.setColor("000000");
    value.setSpace(new BigInteger("0"));
    value.setSz(new BigInteger("3"));
    pBdr.setBetween(value);
    pPr.setPBdr(pBdr);
    setParagraphSpacing(factory, p, jcEnumeration, "0", "0");
    return p;
}
Also used : P(org.docx4j.wml.P) Drawing(org.docx4j.wml.Drawing) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) PBdr(org.docx4j.wml.PPrBase.PBdr) CTBorder(org.docx4j.wml.CTBorder) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger) Inline(org.docx4j.dml.wordprocessingDrawing.Inline) BinaryPartAbstractImage(org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)

Example 12 with Jc

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

the class Docx4J_简单例子2 method setParagraphSpacing.

// 设置段落间距
public void setParagraphSpacing(ObjectFactory factory, P p, JcEnumeration jcEnumeration, String before, String after) {
    PPr pPr = p.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    Spacing spacing = new Spacing();
    spacing.setBefore(new BigInteger(before));
    spacing.setAfter(new BigInteger(after));
    spacing.setLineRule(STLineSpacingRule.AUTO);
    pPr.setSpacing(spacing);
    p.setPPr(pPr);
}
Also used : PPr(org.docx4j.wml.PPr) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger) Spacing(org.docx4j.wml.PPrBase.Spacing)

Example 13 with Jc

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

the class Docx4J_简单例子2 method setTableAlign.

// 表格水平对齐方式
public void setTableAlign(ObjectFactory factory, Tbl table, JcEnumeration jcEnumeration) {
    TblPr tablePr = table.getTblPr();
    if (tablePr == null) {
        tablePr = factory.createTblPr();
    }
    Jc jc = tablePr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    tablePr.setJc(jc);
    table.setTblPr(tablePr);
}
Also used : STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) TblPr(org.docx4j.wml.TblPr)

Example 14 with Jc

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

the class Docx4j_Helper method createParagraphWithHAlign.

/**
 * 创建段落设置水平对齐方式
 * @return
 */
private P createParagraphWithHAlign() {
    P p;
    PPr pPr;
    p = Docx4j_Helper.factory.createP();
    pPr = Docx4j_Helper.factory.createPPr();
    Jc jc = Docx4j_Helper.factory.createJc();
    jc.setVal(JcEnumeration.CENTER);
    pPr.setJc(jc);
    p.setPPr(pPr);
    return p;
}
Also used : P(org.docx4j.wml.P) PPr(org.docx4j.wml.PPr) Jc(org.docx4j.wml.Jc)

Example 15 with Jc

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

the class Docx4j_创建批注_S3_Test method setParagraphAlign.

// 段落对齐方式
public void setParagraphAlign(ObjectFactory factory, P p, JcEnumeration jcEnumeration, TextAlignment textAlign) {
    PPr pPr = p.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    if (jcEnumeration != null) {
        Jc jc = pPr.getJc();
        if (jc == null) {
            jc = new Jc();
        }
        jc.setVal(jcEnumeration);
        pPr.setJc(jc);
    }
    if (textAlign != null) {
        pPr.setTextAlignment(textAlign);
    }
    p.setPPr(pPr);
}
Also used : PPr(org.docx4j.wml.PPr) Jc(org.docx4j.wml.Jc)

Aggregations

Jc (org.docx4j.wml.Jc)33 PPr (org.docx4j.wml.PPr)29 CTVerticalJc (org.docx4j.wml.CTVerticalJc)23 STVerticalJc (org.docx4j.wml.STVerticalJc)23 R (org.docx4j.wml.R)18 P (org.docx4j.wml.P)16 BigInteger (java.math.BigInteger)11 Text (org.docx4j.wml.Text)10 CTBorder (org.docx4j.wml.CTBorder)8 PBdr (org.docx4j.wml.PPrBase.PBdr)8 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)5 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)5 Drawing (org.docx4j.wml.Drawing)5 TblPr (org.docx4j.wml.TblPr)5 Ftr (org.docx4j.wml.Ftr)4 RPr (org.docx4j.wml.RPr)4 Hdr (org.docx4j.wml.Hdr)3 Ind (org.docx4j.wml.PPrBase.Ind)2 Spacing (org.docx4j.wml.PPrBase.Spacing)2 ParaRPr (org.docx4j.wml.ParaRPr)2