use of org.docx4j.wml.R in project docx4j-template by vindell.
the class Docx4J_简单例子 method addFieldBegin.
public void addFieldBegin(ObjectFactory factory, P paragraph) {
R run = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
run.getContent().add(fldchar);
paragraph.getContent().add(run);
}
use of org.docx4j.wml.R in project docx4j-template by vindell.
the class Docx4J_简单例子 method addTableCell.
// 新增单元格
public void addTableCell(ObjectFactory factory, WordprocessingMLPackage wordMLPackage, Tr tableRow, String content, RPr rpr, JcEnumeration jcEnumeration, boolean hasBgColor, String backgroudColor) {
Tc tableCell = factory.createTc();
P p = factory.createP();
setParagraphAlign(factory, p, jcEnumeration);
Text t = factory.createText();
t.setValue(content);
R run = factory.createR();
// 设置表格内容字体样式
run.setRPr(rpr);
run.getContent().add(t);
p.getContent().add(run);
tableCell.getContent().add(p);
if (hasBgColor) {
TcPr tcPr = tableCell.getTcPr();
if (tcPr == null) {
tcPr = factory.createTcPr();
}
CTShd shd = tcPr.getShd();
if (shd == null) {
shd = factory.createCTShd();
}
shd.setColor("auto");
shd.setFill(backgroudColor);
tcPr.setShd(shd);
tableCell.setTcPr(tcPr);
}
tableRow.getContent().add(tableCell);
}
use of org.docx4j.wml.R in project docx4j-template by vindell.
the class Docx4J_简单例子2 method createImageParagraph.
// 段落中插入文字和图片
public P createImageParagraph(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, P p, String fileName, String content, byte[] bytes, JcEnumeration jcEnumeration) throws Exception {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
Inline inline = imagePart.createImageInline(fileName, "这是图片", 1, 2, false);
Text text = factory.createText();
text.setValue(content);
text.setSpace("preserve");
R run = factory.createR();
p.getContent().add(run);
run.getContent().add(text);
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);
setParagraphSpacing(factory, p, jcEnumeration, "0", "0");
return p;
}
use of org.docx4j.wml.R in project docx4j-template by vindell.
the class Docx4J_简单例子2 method getTextHdr.
public Hdr getTextHdr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, JcEnumeration jcEnumeration) throws Exception {
Hdr hdr = factory.createHdr();
P headP = factory.createP();
Text text = factory.createText();
text.setValue(content);
R run = factory.createR();
run.getContent().add(text);
headP.getContent().add(run);
PPr pPr = headP.getPPr();
if (pPr == null) {
pPr = factory.createPPr();
}
Jc jc = pPr.getJc();
if (jc == null) {
jc = new Jc();
}
jc.setVal(jcEnumeration);
pPr.setJc(jc);
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);
headP.setPPr(pPr);
setParagraphSpacing(factory, headP, jcEnumeration, "0", "0");
hdr.getContent().add(headP);
hdr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, jcEnumeration));
return hdr;
}
use of org.docx4j.wml.R in project docx4j-template by vindell.
the class Docx4J_简单例子2 method addFieldBegin.
public void addFieldBegin(ObjectFactory factory, P paragraph) {
R run = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
run.getContent().add(fldchar);
paragraph.getContent().add(run);
}
Aggregations