use of org.docx4j.wml.R 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.R in project docx4j-template by vindell.
the class AddingPageNrToFooter method addPageNumberField.
/**
* Creating the page number field is nearly the same as creating the field in
* the TOC example. The only difference is in the value. We use the PAGE
* command, which prints the number of the current page, together with the
* MERGEFORMAT switch, which indicates that the current formatting should be
* preserved when the field is updated.
*
* @param paragraph
*/
private static void addPageNumberField(P paragraph) {
R run = factory.createR();
Text txt = new Text();
txt.setSpace("preserve");
txt.setValue(" PAGE \\* MERGEFORMAT ");
run.getContent().add(factory.createRInstrText(txt));
paragraph.getContent().add(run);
}
use of org.docx4j.wml.R in project docx4j-template by vindell.
the class AddingPageNrToFooter method addFieldBegin.
/**
* Every fields needs to be delimited by complex field characters. This method
* adds the delimiter that precedes the actual field to the given paragraph.
* @param paragraph
*/
private static void addFieldBegin(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 AddingTableOfContent method addFieldEnd.
/**
* 每个域都需要用复杂的域字符来确定界限. 本方法向给定段落添加在真正域之后的界定符.
*
* 跟前面一样, 从创建可运行块开始, 然后创建域字符标记域的结束, 最后将域字符转换成JAXB元素并
* 将其添加到可运行块, 可运行块再添加到段落中.
*
* @param paragraph
*/
private static void addFieldEnd(P paragraph) {
R run = factory.createR();
FldChar fldcharend = factory.createFldChar();
fldcharend.setFldCharType(STFldCharType.END);
run.getContent().add(getWrappedFldChar(fldcharend));
paragraph.getContent().add(run);
}
use of org.docx4j.wml.R 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