Search in sources :

Example 6 with Text

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

the class Docx4J_例子2 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 7 with Text

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

the class Docx4J_例子2 method getTextFtr.

public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    Ftr ftr = factory.createFtr();
    P footerP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    footerP.getContent().add(run);
    PPr pPr = footerP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    footerP.setPPr(pPr);
    setParagraphSpacing(factory, footerP, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    if (isUnderLine) {
        PBdr pBdr = pPr.getPBdr();
        if (pBdr == null) {
            pBdr = factory.createPPrBasePBdr();
        }
        CTBorder value = new CTBorder();
        value.setVal(STBorder.SINGLE);
        value.setColor("000000");
        value.setSpace(new BigInteger("0"));
        value.setSz(new BigInteger(underLineSz));
        pBdr.setBetween(value);
        pPr.setPBdr(pBdr);
        footerP.setPPr(pPr);
    }
    ftr.getContent().add(footerP);
    if (isUnderLine) {
        ftr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, underLineSz, jcEnumeration));
    }
    return ftr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Ftr(org.docx4j.wml.Ftr) PBdr(org.docx4j.wml.PPrBase.PBdr) CTBorder(org.docx4j.wml.CTBorder) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger) Text(org.docx4j.wml.Text)

Example 8 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 9 with Text

use of org.docx4j.wml.Text 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 10 with Text

use of org.docx4j.wml.Text 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)

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