use of org.docx4j.wml.P in project docx4j-template by vindell.
the class AddingAnInlineImage method addInlineImageToParagraph.
/**
* 创建一个对象工厂并用它创建一个段落和一个可运行块R.
* 然后将可运行块添加到段落中. 接下来创建一个图画并将其添加到可运行块R中. 最后我们将内联
* 对象添加到图画中并返回段落对象.
*
* @param inline 包含图片的内联对象.
* @return 包含图片的段落
*/
private 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;
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class AddingAnInlineImageToTable method addInlineImageToParagraph.
/**
* 向新的段落中添加内联图片并返回这个段落.
* 这个方法与前面例子中的方法没有区别.
* @param inline
* @return
*/
private 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.P in project docx4j-template by vindell.
the class AddingTableOfContent method addTableOfContent.
/**
* 将目录表添加到文档.
*
* 首先我们创建段落. 然后添加标记域开始的指示符, 然后添加域内容(真正的目录表), 接着添加域
* 结束的指示符. 最后将段落添加到给定文档的JAXB元素中.
*
* @param documentPart
*/
private static void addTableOfContent(MainDocumentPart documentPart) {
P paragraph = factory.createP();
addFieldBegin(paragraph);
addTableOfContentField(paragraph);
addFieldEnd(paragraph);
documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
use of org.docx4j.wml.P 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;
}
use of org.docx4j.wml.P in project docx4j-template by vindell.
the class AddingAPageBreak method addPageBreak.
/**
* 向文档添加一个换行符
*/
private static void addPageBreak() {
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
Br breakObj = new Br();
breakObj.setType(STBrType.PAGE);
P paragraph = factory.createP();
paragraph.getContent().add(breakObj);
documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
Aggregations