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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations