Search in sources :

Example 1 with Spacing

use of org.docx4j.wml.PPrBase.Spacing 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 2 with Spacing

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

the class Docx4j_工具类_S3_Test method setParagraphSpacing.

/**
 * @param isSpace
 *            是否设置段前段后值
 * @param before
 *            段前磅数
 * @param after
 *            段后磅数
 * @param beforeLines
 *            段前行数
 * @param afterLines
 *            段后行数
 * @param isLine
 *            是否设置行距
 * @param lineValue
 *            行距值
 * @param sTLineSpacingRule
 *            自动auto 固定exact 最小 atLeast 1磅=20 1行=100 单倍行距=240
 */
public void setParagraphSpacing(P p, boolean isSpace, String before, String after, String beforeLines, String afterLines, boolean isLine, String lineValue, STLineSpacingRule sTLineSpacingRule) {
    PPr pPr = getPPr(p);
    Spacing spacing = pPr.getSpacing();
    if (spacing == null) {
        spacing = new Spacing();
        pPr.setSpacing(spacing);
    }
    if (isSpace) {
        if (StringUtils.isNotBlank(before)) {
            // 段前磅数
            spacing.setBefore(new BigInteger(before));
        }
        if (StringUtils.isNotBlank(after)) {
            // 段后磅数
            spacing.setAfter(new BigInteger(after));
        }
        if (StringUtils.isNotBlank(beforeLines)) {
            // 段前行数
            spacing.setBeforeLines(new BigInteger(beforeLines));
        }
        if (StringUtils.isNotBlank(afterLines)) {
            // 段后行数
            spacing.setAfterLines(new BigInteger(afterLines));
        }
    }
    if (isLine) {
        if (StringUtils.isNotBlank(lineValue)) {
            spacing.setLine(new BigInteger(lineValue));
        }
        if (sTLineSpacingRule != null) {
            spacing.setLineRule(sTLineSpacingRule);
        }
    }
}
Also used : PPr(org.docx4j.wml.PPr) BigInteger(java.math.BigInteger) Spacing(org.docx4j.wml.PPrBase.Spacing)

Example 3 with Spacing

use of org.docx4j.wml.PPrBase.Spacing in project flexmark-java by vsch.

the class DocxContextImpl method addBlankLine.

@Override
public void addBlankLine(final BigInteger size, final String styleId) {
    if (size.compareTo(BigInteger.ZERO) > 0) {
        // now add empty for spacing
        P p = myFactory.createP();
        PPr pPr = myFactory.createPPr();
        p.setPPr(pPr);
        myParaContainer.addP(p);
        if (styleId != null && !styleId.isEmpty()) {
            if (pPr.getPStyle() == null) {
                PStyle pStyle = myDocxHelper.myFactory.createPPrBasePStyle();
                pPr.setPStyle(pStyle);
            }
            pPr.getPStyle().setVal(styleId);
        }
        // Create new Spacing which we override
        Spacing spacing = myFactory.createPPrBaseSpacing();
        pPr.setSpacing(spacing);
        spacing.setBefore(BigInteger.ZERO);
        spacing.setAfter(BigInteger.ZERO);
        spacing.setLine(size);
        spacing.setLineRule(STLineSpacingRule.EXACT);
    }
}
Also used : PStyle(org.docx4j.wml.PPrBase.PStyle) Spacing(org.docx4j.wml.PPrBase.Spacing)

Example 4 with Spacing

use of org.docx4j.wml.PPrBase.Spacing in project mdw-designer by CenturyLinkCloud.

the class DocxBuilder method createSpacing.

public Spacing createSpacing(int before, int after) {
    Spacing spacing = new Spacing();
    spacing.setBefore(BigInteger.valueOf(before));
    spacing.setAfter(BigInteger.valueOf(after));
    return spacing;
}
Also used : Spacing(org.docx4j.wml.PPrBase.Spacing)

Example 5 with Spacing

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

the class Docx4J_例子2 method setParagraphSpacing.

// 设置段间距-->行距 段前段后距离
// 段前段后可以设置行和磅 行距只有磅
// 段前磅值和行值同时设置,只有行值起作用
// TODO 1磅=20 1行=100 单倍行距=240 为什么是这个值不知道
/**
 * @param jcEnumeration
 *            对齐方式
 * @param isSpace
 *            是否设置段前段后值
 * @param before
 *            段前磅数
 * @param after
 *            段后磅数
 * @param beforeLines
 *            段前行数
 * @param afterLines
 *            段后行数
 * @param isLine
 *            是否设置行距
 * @param lineValue
 *            行距值
 * @param sTLineSpacingRule
 *            自动auto 固定exact 最小 atLeast
 */
public void setParagraphSpacing(ObjectFactory factory, P p, JcEnumeration jcEnumeration, boolean isSpace, String before, String after, String beforeLines, String afterLines, boolean isLine, String lineValue, STLineSpacingRule sTLineSpacingRule) {
    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();
    if (isSpace) {
        if (before != null) {
            // 段前磅数
            spacing.setBefore(new BigInteger(before));
        }
        if (after != null) {
            // 段后磅数
            spacing.setAfter(new BigInteger(after));
        }
        if (beforeLines != null) {
            // 段前行数
            spacing.setBeforeLines(new BigInteger(beforeLines));
        }
        if (afterLines != null) {
            // 段后行数
            spacing.setAfterLines(new BigInteger(afterLines));
        }
    }
    if (isLine) {
        if (lineValue != null) {
            spacing.setLine(new BigInteger(lineValue));
        }
        spacing.setLineRule(sTLineSpacingRule);
    }
    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)

Aggregations

Spacing (org.docx4j.wml.PPrBase.Spacing)7 BigInteger (java.math.BigInteger)5 PPr (org.docx4j.wml.PPr)5 CTVerticalJc (org.docx4j.wml.CTVerticalJc)3 Jc (org.docx4j.wml.Jc)2 STVerticalJc (org.docx4j.wml.STVerticalJc)2 CTShd (org.docx4j.wml.CTShd)1 P (org.docx4j.wml.P)1 PStyle (org.docx4j.wml.PPrBase.PStyle)1 R (org.docx4j.wml.R)1 Tc (org.docx4j.wml.Tc)1 TcPr (org.docx4j.wml.TcPr)1 Text (org.docx4j.wml.Text)1