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, 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;
}
use of org.docx4j.wml.Jc 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);
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4J_简单例子2 method setTableAlign.
// 表格水平对齐方式
public void setTableAlign(ObjectFactory factory, Tbl table, JcEnumeration jcEnumeration) {
TblPr tablePr = table.getTblPr();
if (tablePr == null) {
tablePr = factory.createTblPr();
}
Jc jc = tablePr.getJc();
if (jc == null) {
jc = new Jc();
}
jc.setVal(jcEnumeration);
tablePr.setJc(jc);
table.setTblPr(tablePr);
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4j_Helper method createParagraphWithHAlign.
/**
* 创建段落设置水平对齐方式
* @return
*/
private P createParagraphWithHAlign() {
P p;
PPr pPr;
p = Docx4j_Helper.factory.createP();
pPr = Docx4j_Helper.factory.createPPr();
Jc jc = Docx4j_Helper.factory.createJc();
jc.setVal(JcEnumeration.CENTER);
pPr.setJc(jc);
p.setPPr(pPr);
return p;
}
use of org.docx4j.wml.Jc in project docx4j-template by vindell.
the class Docx4j_创建批注_S3_Test method setParagraphAlign.
// 段落对齐方式
public void setParagraphAlign(ObjectFactory factory, P p, JcEnumeration jcEnumeration, TextAlignment textAlign) {
PPr pPr = p.getPPr();
if (pPr == null) {
pPr = factory.createPPr();
}
if (jcEnumeration != null) {
Jc jc = pPr.getJc();
if (jc == null) {
jc = new Jc();
}
jc.setVal(jcEnumeration);
pPr.setJc(jc);
}
if (textAlign != null) {
pPr.setTextAlignment(textAlign);
}
p.setPPr(pPr);
}
Aggregations