use of org.docx4j.wml.ObjectFactory in project docx4j-template by vindell.
the class ParagraphUtils method addInlineImageToParagraph.
/**
* 向新的段落中添加内联图片并返回这个段落.
* 这个方法与前面例子中的方法没有区别.
* @param inline
* @return
*/
public static P addInlineImageToParagraph(Inline inline) {
// Now add the in-line image to a paragraph
ObjectFactory factory = new ObjectFactory();
P paragraph = factory.createP();
R run = factory.createR();
paragraph.getContent().add(run);
Drawing drawing = factory.createDrawing();
run.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
return paragraph;
}
use of org.docx4j.wml.ObjectFactory in project mdw-designer by CenturyLinkCloud.
the class DocxBuilder method createBoldParagraph.
public P createBoldParagraph(String style, String text) {
ObjectFactory factory = Context.getWmlObjectFactory();
RPr rprDoc = factory.createRPr();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
rprDoc.setB(b);
P pDoc = getMdp().createStyledParagraphOfText(style, text);
R rDoc = (R) pDoc.getContent().get(0);
rDoc.setRPr(rprDoc);
return pDoc;
}
use of org.docx4j.wml.ObjectFactory in project mdw-designer by CenturyLinkCloud.
the class DocxBuilder method addBulletList.
public void addBulletList(List<String> items) throws Exception {
if (bulletNum == null) {
bulletNum = getNdp().addAbstractListNumberingDefinition((Numbering.AbstractNum) XmlUtils.unmarshalString(getFragment("bulletNumbering")));
bulletNumId = bulletNum.getNumId();
} else {
bulletNumId = BigInteger.valueOf(ndp.restart(bulletNumId.longValue(), 0, 1));
}
for (String item : items) {
ObjectFactory factory = Context.getWmlObjectFactory();
P listP = factory.createP();
Text t = factory.createText();
t.setValue(item);
R listRun = factory.createR();
listRun.getContent().add(t);
listP.getContent().add(listRun);
PPr listPpr = factory.createPPr();
listP.setPPr(listPpr);
listPpr.setNumPr(createBulletListNumPr());
PStyle pStyle = factory.createPPrBasePStyle();
pStyle.setVal("ListParagraph");
listPpr.setPStyle(pStyle);
getMdp().addObject(listP);
}
}
use of org.docx4j.wml.ObjectFactory in project mdw-designer by CenturyLinkCloud.
the class DocxBuilder method addBoldParagraph.
public P addBoldParagraph(String text) {
ObjectFactory factory = Context.getWmlObjectFactory();
RPr rprDoc = factory.createRPr();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
rprDoc.setB(b);
P pDoc = getMdp().addParagraphOfText(text);
R rDoc = (R) pDoc.getContent().get(0);
rDoc.setRPr(rprDoc);
return pDoc;
}
use of org.docx4j.wml.ObjectFactory in project mdw-designer by CenturyLinkCloud.
the class DocxBuilder method createParagraph.
public P createParagraph(String text, int fontSize, boolean bold) {
ObjectFactory factory = Context.getWmlObjectFactory();
RPr rprDoc = factory.createRPr();
if (fontSize != 0) {
HpsMeasure size = new HpsMeasure();
size.setVal(BigInteger.valueOf(fontSize * 2));
rprDoc.setSz(size);
}
if (bold) {
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
rprDoc.setB(b);
}
P pDoc = getMdp().createParagraphOfText(text);
R rDoc = (R) pDoc.getContent().get(0);
rDoc.setRPr(rprDoc);
return pDoc;
}
Aggregations