Search in sources :

Example 11 with R

use of org.docx4j.wml.R 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 12 with R

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

the class Docx4J_例子2 method addFieldBegin.

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

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

the class Docx4J_简单例子 method addPageTextField.

private void addPageTextField(ObjectFactory factory, P paragraph, String value) {
    R run = factory.createR();
    Text txt = new Text();
    txt.setSpace("preserve");
    txt.setValue(value);
    run.getContent().add(txt);
    paragraph.getContent().add(run);
}
Also used : R(org.docx4j.wml.R) Text(org.docx4j.wml.Text)

Example 14 with R

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

the class Docx4J_简单例子 method addParagraphTest.

public void addParagraphTest(WordprocessingMLPackage wordMLPackage, MainDocumentPart t, ObjectFactory factory) throws Exception {
    RPr titleRPr = getRPr(factory, "黑体", "000000", "28", STHint.EAST_ASIA, true, false, false, false);
    RPr boldRPr = getRPr(factory, "宋体", "000000", "22", STHint.EAST_ASIA, true, false, false, false);
    RPr fontRPr = getRPr(factory, "宋体", "000000", "20", STHint.EAST_ASIA, false, false, false, false);
    P paragraph = factory.createP();
    setParagraphAlign(factory, paragraph, JcEnumeration.CENTER);
    Text txt = factory.createText();
    txt.setValue("七年级上册Unit2 This is just a test. sectionA测试卷答题卡");
    R run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(titleRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    setParagraphAlign(factory, paragraph, JcEnumeration.CENTER);
    txt = factory.createText();
    txt.setValue("班级:________    姓名:________");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("一、单选题");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(boldRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("1.下列有关仪器用途的说法错误的是(    )");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("A.烧杯用于较多量试剂的反应容器");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("B.烧杯用于较多量试剂的反应容器");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("C.烧杯用于较多量试剂的反应容器");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
    paragraph = factory.createP();
    txt = factory.createText();
    txt.setValue("D.烧杯用于较多量试剂的反应容器");
    run = factory.createR();
    run.getContent().add(txt);
    run.setRPr(fontRPr);
    paragraph.getContent().add(run);
    t.addObject(paragraph);
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) RPr(org.docx4j.wml.RPr) Text(org.docx4j.wml.Text)

Example 15 with R

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

the class Docx4J_简单例子 method addFieldEnd.

public void addFieldEnd(ObjectFactory factory, P paragraph) {
    FldChar fldcharend = factory.createFldChar();
    fldcharend.setFldCharType(STFldCharType.END);
    R run3 = factory.createR();
    run3.getContent().add(fldcharend);
    paragraph.getContent().add(run3);
}
Also used : R(org.docx4j.wml.R) FldChar(org.docx4j.wml.FldChar)

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