Search in sources :

Example 6 with CTBorder

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

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

the class Docx4J_简单例子2 method addBorders.

// 表格增加边框
public void addBorders(Tbl table, String borderSize) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger(borderSize));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TblBorders borders = new TblBorders();
    borders.setBottom(border);
    borders.setLeft(border);
    borders.setRight(border);
    borders.setTop(border);
    borders.setInsideH(border);
    borders.setInsideV(border);
    table.getTblPr().setTblBorders(borders);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 8 with CTBorder

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

the class Docx4jStyle_S3 method setCellBorders.

public void setCellBorders(Tc tableCell, boolean borderTop, boolean borderRight, boolean borderBottom, boolean borderLeft) {
    TcPr tableCellProperties = tableCell.getTcPr();
    if (tableCellProperties == null) {
        tableCellProperties = new TcPr();
        tableCell.setTcPr(tableCellProperties);
    }
    CTBorder border = new CTBorder();
    // border.setColor("auto");
    border.setColor("0000FF");
    border.setSz(new BigInteger("20"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TcBorders borders = new TcBorders();
    if (borderBottom) {
        borders.setBottom(border);
    }
    if (borderTop) {
        borders.setTop(border);
    }
    if (borderLeft) {
        borders.setLeft(border);
    }
    if (borderRight) {
        borders.setRight(border);
    }
    tableCellProperties.setTcBorders(borders);
}
Also used : TcPr(org.docx4j.wml.TcPr) CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TcBorders(org.docx4j.wml.TcPrInner.TcBorders)

Example 9 with CTBorder

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

the class Docx4j_工具类_S3_Test method addRPrBorderStyle.

/**
 * @Description: 设置字符边框
 */
public void addRPrBorderStyle(RPr runProperties, String size, STBorder bordType, String space, String color) {
    CTBorder value = new CTBorder();
    if (StringUtils.isNotBlank(color)) {
        value.setColor(color);
    }
    if (StringUtils.isNotBlank(size)) {
        value.setSz(new BigInteger(size));
    }
    if (StringUtils.isNotBlank(space)) {
        value.setSpace(new BigInteger(space));
    }
    if (bordType != null) {
        value.setVal(bordType);
    }
    runProperties.setBdr(value);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger)

Example 10 with CTBorder

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

the class SettingColumnWidthForTable method addBorders.

/**
 *  本方法为表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TblBorders borders = new TblBorders();
    borders.setBottom(border);
    borders.setLeft(border);
    borders.setRight(border);
    borders.setTop(border);
    borders.setInsideH(border);
    borders.setInsideV(border);
    table.getTblPr().setTblBorders(borders);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Aggregations

CTBorder (org.docx4j.wml.CTBorder)24 BigInteger (java.math.BigInteger)22 P (org.docx4j.wml.P)9 PPr (org.docx4j.wml.PPr)9 TblBorders (org.docx4j.wml.TblBorders)9 TblPr (org.docx4j.wml.TblPr)9 CTVerticalJc (org.docx4j.wml.CTVerticalJc)8 Jc (org.docx4j.wml.Jc)8 PBdr (org.docx4j.wml.PPrBase.PBdr)8 R (org.docx4j.wml.R)8 STVerticalJc (org.docx4j.wml.STVerticalJc)8 Text (org.docx4j.wml.Text)3 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)2 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)2 Drawing (org.docx4j.wml.Drawing)2 Ftr (org.docx4j.wml.Ftr)2 Hdr (org.docx4j.wml.Hdr)2 ParaRPr (org.docx4j.wml.ParaRPr)2 RPr (org.docx4j.wml.RPr)2 TcPr (org.docx4j.wml.TcPr)2