Search in sources :

Example 1 with CTLineNumber

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

BigInteger (java.math.BigInteger)1 CTLineNumber (org.docx4j.wml.CTLineNumber)1 SectPr (org.docx4j.wml.SectPr)1