Search in sources :

Example 16 with SectPr

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

the class Docx4j_工具类_S3_Test method setDocMarginSpace.

/**
 * @Description:设置页边距
 */
public void setDocMarginSpace(WordprocessingMLPackage wordPackage, ObjectFactory factory, String top, String left, String bottom, String right) {
    SectPr sectPr = getDocSectPr(wordPackage);
    PgMar pg = sectPr.getPgMar();
    if (pg == null) {
        pg = factory.createSectPrPgMar();
        sectPr.setPgMar(pg);
    }
    if (StringUtils.isNotBlank(top)) {
        pg.setTop(new BigInteger(top));
    }
    if (StringUtils.isNotBlank(bottom)) {
        pg.setBottom(new BigInteger(bottom));
    }
    if (StringUtils.isNotBlank(left)) {
        pg.setLeft(new BigInteger(left));
    }
    if (StringUtils.isNotBlank(right)) {
        pg.setRight(new BigInteger(right));
    }
}
Also used : PgMar(org.docx4j.wml.SectPr.PgMar) SectPr(org.docx4j.wml.SectPr) BigInteger(java.math.BigInteger)

Example 17 with SectPr

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

the class Docx4j_工具类_S3_Test method setDocumentSize.

/**
 * @Description: 设置页面大小及纸张方向 landscape横向
 */
public void setDocumentSize(WordprocessingMLPackage wordPackage, ObjectFactory factory, String width, String height, STPageOrientation stValue) {
    SectPr sectPr = getDocSectPr(wordPackage);
    PgSz pgSz = sectPr.getPgSz();
    if (pgSz == null) {
        pgSz = factory.createSectPrPgSz();
        sectPr.setPgSz(pgSz);
    }
    if (StringUtils.isNotBlank(width)) {
        pgSz.setW(new BigInteger(width));
    }
    if (StringUtils.isNotBlank(height)) {
        pgSz.setH(new BigInteger(height));
    }
    if (stValue != null) {
        pgSz.setOrient(stValue);
    }
}
Also used : SectPr(org.docx4j.wml.SectPr) BigInteger(java.math.BigInteger) PgSz(org.docx4j.wml.SectPr.PgSz)

Example 18 with SectPr

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

the class Docx4j_工具类_S3_Test method setDocInNumType.

/**
 * @Description: 设置行号
 * @param distance
 *            :距正文距离 1厘米=567
 * @param start
 *            :起始编号(0开始)
 * @param countBy
 *            :行号间隔
 * @param restartType
 *            :STLineNumberRestart.CONTINUOUS(continuous连续编号)<br/>
 *            STLineNumberRestart.NEW_PAGE(每页重新编号)<br/>
 *            STLineNumberRestart.NEW_SECTION(每节重新编号)
 */
public void setDocInNumType(WordprocessingMLPackage wordPackage, String countBy, String distance, String start, STLineNumberRestart restartType) {
    SectPr sectPr = getDocSectPr(wordPackage);
    CTLineNumber lnNumType = sectPr.getLnNumType();
    if (lnNumType == null) {
        lnNumType = new CTLineNumber();
        sectPr.setLnNumType(lnNumType);
    }
    if (StringUtils.isNotBlank(countBy)) {
        lnNumType.setCountBy(new BigInteger(countBy));
    }
    if (StringUtils.isNotBlank(distance)) {
        lnNumType.setDistance(new BigInteger(distance));
    }
    if (StringUtils.isNotBlank(start)) {
        lnNumType.setStart(new BigInteger(start));
    }
    if (restartType != null) {
        lnNumType.setRestart(restartType);
    }
}
Also used : CTLineNumber(org.docx4j.wml.CTLineNumber) SectPr(org.docx4j.wml.SectPr) BigInteger(java.math.BigInteger)

Aggregations

SectPr (org.docx4j.wml.SectPr)18 SectionWrapper (org.docx4j.model.structure.SectionWrapper)8 FooterReference (org.docx4j.wml.FooterReference)5 BigInteger (java.math.BigInteger)4 HeaderReference (org.docx4j.wml.HeaderReference)3 PgMar (org.docx4j.wml.SectPr.PgMar)3 PageDimensions (org.docx4j.model.structure.PageDimensions)2 Body (org.docx4j.wml.Body)2 PgSz (org.docx4j.wml.SectPr.PgSz)2 Type (org.docx4j.wml.SectPr.Type)2 TextDirection (org.docx4j.wml.TextDirection)2 Docx4JException (org.docx4j.openpackaging.exceptions.Docx4JException)1 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)1 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)1 CTLineNumber (org.docx4j.wml.CTLineNumber)1 CTVerticalJc (org.docx4j.wml.CTVerticalJc)1 P (org.docx4j.wml.P)1 PPr (org.docx4j.wml.PPr)1 RPr (org.docx4j.wml.RPr)1 STBrType (org.docx4j.wml.STBrType)1