use of org.docx4j.wml.ObjectFactory in project docx4j-template by vindell.
the class WmlElementUtils method addInlineImageToParagraph.
/**
* 创建一个对象工厂并用它创建一个段落和一个可运行块R.
* 然后将可运行块添加到段落中. 接下来创建一个图画并将其添加到可运行块R中. 最后我们将内联
* 对象添加到图画中并返回段落对象.
*
* @param inline 包含图片的内联对象.
* @return 包含图片的段落
*/
public static P addInlineImageToParagraph(Inline inline) {
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;
}
Aggregations