Search in sources :

Example 1 with PBdr

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

the class Docx4J_例子2 method getTextHdr.

public Hdr getTextHdr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    Hdr hdr = factory.createHdr();
    P headP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    headP.getContent().add(run);
    PPr pPr = headP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    if (isUnderLine) {
        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(underLineSz));
        pBdr.setBetween(value);
        pPr.setPBdr(pBdr);
        headP.setPPr(pPr);
    }
    setParagraphSpacing(factory, headP, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    hdr.getContent().add(headP);
    if (isUnderLine) {
        hdr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, underLineSz, jcEnumeration));
    }
    return hdr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) PBdr(org.docx4j.wml.PPrBase.PBdr) CTBorder(org.docx4j.wml.CTBorder) Hdr(org.docx4j.wml.Hdr) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger) Text(org.docx4j.wml.Text)

Example 2 with PBdr

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

the class Docx4J_例子2 method createFooterWithPageNr.

public Ftr createFooterWithPageNr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    Ftr ftr = factory.createFtr();
    P paragraph = factory.createP();
    RPr fontRPr = getRPr(factory, "宋体", "000000", "20", STHint.EAST_ASIA, false, false, false, false);
    R run = factory.createR();
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    addPageTextField(factory, paragraph, "第");
    addFieldBegin(factory, paragraph);
    addPageNumberField(factory, paragraph);
    addFieldEnd(factory, paragraph);
    addPageTextField(factory, paragraph, "页");
    addPageTextField(factory, paragraph, " 总共");
    addFieldBegin(factory, paragraph);
    addTotalPageNumberField(factory, paragraph);
    addFieldEnd(factory, paragraph);
    addPageTextField(factory, paragraph, "页");
    setParagraphSpacing(factory, paragraph, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    PPr pPr = paragraph.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    if (isUnderLine) {
        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(underLineSz));
        pBdr.setBetween(value);
        pPr.setPBdr(pBdr);
        paragraph.setPPr(pPr);
    }
    ftr.getContent().add(paragraph);
    if (isUnderLine) {
        ftr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, underLineSz, jcEnumeration));
    }
    return ftr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Ftr(org.docx4j.wml.Ftr) RPr(org.docx4j.wml.RPr) ParaRPr(org.docx4j.wml.ParaRPr) 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)

Example 3 with PBdr

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

the class Docx4J_例子2 method getTextFtr.

public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    Ftr ftr = factory.createFtr();
    P footerP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    footerP.getContent().add(run);
    PPr pPr = footerP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    footerP.setPPr(pPr);
    setParagraphSpacing(factory, footerP, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    if (isUnderLine) {
        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(underLineSz));
        pBdr.setBetween(value);
        pPr.setPBdr(pBdr);
        footerP.setPPr(pPr);
    }
    ftr.getContent().add(footerP);
    if (isUnderLine) {
        ftr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, underLineSz, jcEnumeration));
    }
    return ftr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Ftr(org.docx4j.wml.Ftr) 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) Text(org.docx4j.wml.Text)

Example 4 with PBdr

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

the class Docx4J_例子2 method createHeaderBlankP.

public P createHeaderBlankP(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    P p = factory.createP();
    R run = factory.createR();
    p.getContent().add(run);
    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);
    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(underLineSz));
    pBdr.setBetween(value);
    pPr.setPBdr(pBdr);
    p.setPPr(pPr);
    setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    return p;
}
Also used : P(org.docx4j.wml.P) 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)

Example 5 with PBdr

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

Aggregations

PPr (org.docx4j.wml.PPr)10 PBdr (org.docx4j.wml.PPrBase.PBdr)10 BigInteger (java.math.BigInteger)8 CTBorder (org.docx4j.wml.CTBorder)8 CTVerticalJc (org.docx4j.wml.CTVerticalJc)8 Jc (org.docx4j.wml.Jc)8 P (org.docx4j.wml.P)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)1 RPr (org.docx4j.wml.RPr)1