use of org.docx4j.wml.Jc 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);
}
use of org.docx4j.wml.Jc 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, boolean isUnderLine, String underLineSize, 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);
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(underLineSize));
pBdr.setBetween(value);
pPr.setPBdr(pBdr);
}
setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
return p;
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4J_简单例子 method getTextFtr.
public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, 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);
ftr.getContent().add(footerP);
return ftr;
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4J_简单例子 method setParagraphAlign.
// 水平对齐方式
// TODO 垂直对齐没写
public void setParagraphAlign(ObjectFactory factory, P p, JcEnumeration jcEnumeration) {
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);
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4J_简单例子 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);
return p;
}
Aggregations