Search in sources :

Example 11 with Text

use of org.docx4j.wml.Text in project docx4j-template by vindell.

the class Docx4J_简单例子 method getTextHdr.

public Hdr getTextHdr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, JcEnumeration jcEnumeration) throws Exception {
    Hdr hdr = factory.createHdr();
    P headP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    headP.getContent().add(run);
    PPr pPr = headP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    headP.setPPr(pPr);
    hdr.getContent().add(headP);
    return hdr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Hdr(org.docx4j.wml.Hdr) Jc(org.docx4j.wml.Jc) Text(org.docx4j.wml.Text)

Example 12 with Text

use of org.docx4j.wml.Text in project docx4j-template by vindell.

the class Docx4J_简单例子 method addPageNumberField.

public void addPageNumberField(ObjectFactory factory, 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 13 with Text

use of org.docx4j.wml.Text in project docx4j-template by vindell.

the class Docx4J_简单例子2 method addPageNumberField.

public void addPageNumberField(ObjectFactory factory, 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 14 with Text

use of org.docx4j.wml.Text in project docx4j-template by vindell.

the class Docx4J_简单例子2 method addTotalPageNumberField.

public void addTotalPageNumberField(ObjectFactory factory, P paragraph) {
    R run = factory.createR();
    Text txt = new Text();
    txt.setSpace("preserve");
    txt.setValue("NUMPAGES  \\* MERGEFORMAT ");
    run.getContent().add(factory.createRInstrText(txt));
    paragraph.getContent().add(run);
}
Also used : R(org.docx4j.wml.R) Text(org.docx4j.wml.Text)

Example 15 with Text

use of org.docx4j.wml.Text in project docx4j-template by vindell.

the class Docx4j_创建批注_S3_Test method createCommentRound.

// 创建批注(选定范围)
public void createCommentRound(ObjectFactory factory, P p, String pContent, String commentContent, RPr fontRPr, RPr commentRPr, BigInteger commentId, Comments comments) throws Exception {
    CommentRangeStart startComment = factory.createCommentRangeStart();
    startComment.setId(commentId);
    p.getContent().add(startComment);
    R run = factory.createR();
    Text txt = factory.createText();
    txt.setValue(pContent);
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    p.getContent().add(run);
    CommentRangeEnd endComment = factory.createCommentRangeEnd();
    endComment.setId(commentId);
    p.getContent().add(endComment);
    Comment commentOne = createComment(factory, commentId, "系统管理员", new Date(), commentContent, commentRPr);
    comments.getComment().add(commentOne);
    p.getContent().add(createRunCommentReference(factory, commentId));
}
Also used : CommentRangeEnd(org.docx4j.wml.CommentRangeEnd) Comment(org.docx4j.wml.Comments.Comment) R(org.docx4j.wml.R) Text(org.docx4j.wml.Text) CommentRangeStart(org.docx4j.wml.CommentRangeStart) Date(java.util.Date)

Aggregations

Text (org.docx4j.wml.Text)62 R (org.docx4j.wml.R)53 P (org.docx4j.wml.P)32 PPr (org.docx4j.wml.PPr)14 RPr (org.docx4j.wml.RPr)12 Jc (org.docx4j.wml.Jc)10 CTVerticalJc (org.docx4j.wml.CTVerticalJc)9 File (java.io.File)8 Tc (org.docx4j.wml.Tc)7 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)6 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)6 STVerticalJc (org.docx4j.wml.STVerticalJc)6 BigInteger (java.math.BigInteger)5 Br (org.docx4j.wml.Br)5 ObjectFactory (org.docx4j.wml.ObjectFactory)5 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)4 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)4 CTShd (org.docx4j.wml.CTShd)4 Ftr (org.docx4j.wml.Ftr)4 Tbl (org.docx4j.wml.Tbl)4