Search in sources :

Example 86 with R

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;
}
Also used : P(org.docx4j.wml.P) Drawing(org.docx4j.wml.Drawing) R(org.docx4j.wml.R) ObjectFactory(org.docx4j.wml.ObjectFactory)

Example 87 with R

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);
}
Also used : R(org.docx4j.wml.R) Text(org.docx4j.wml.Text)

Example 88 with R

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);
}
Also used : R(org.docx4j.wml.R) FldChar(org.docx4j.wml.FldChar)

Example 89 with R

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);
}
Also used : R(org.docx4j.wml.R) FldChar(org.docx4j.wml.FldChar)

Example 90 with R

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;
}
Also used : P(org.docx4j.wml.P) Drawing(org.docx4j.wml.Drawing) R(org.docx4j.wml.R) ObjectFactory(org.docx4j.wml.ObjectFactory)

Aggregations

R (org.docx4j.wml.R)93 P (org.docx4j.wml.P)58 Text (org.docx4j.wml.Text)53 PPr (org.docx4j.wml.PPr)23 Jc (org.docx4j.wml.Jc)18 RPr (org.docx4j.wml.RPr)18 Drawing (org.docx4j.wml.Drawing)17 ObjectFactory (org.docx4j.wml.ObjectFactory)17 CTVerticalJc (org.docx4j.wml.CTVerticalJc)16 STVerticalJc (org.docx4j.wml.STVerticalJc)13 FldChar (org.docx4j.wml.FldChar)11 BigInteger (java.math.BigInteger)10 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)10 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)10 Tc (org.docx4j.wml.Tc)10 CTBorder (org.docx4j.wml.CTBorder)8 PBdr (org.docx4j.wml.PPrBase.PBdr)8 Ftr (org.docx4j.wml.Ftr)7 File (java.io.File)6 Tr (org.docx4j.wml.Tr)6