use of org.docx4j.wml.ParaRPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method getParaRPr.
public ParaRPr getParaRPr(PPr ppr) {
ParaRPr parRpr = ppr.getRPr();
if (parRpr == null) {
parRpr = new ParaRPr();
ppr.setRPr(parRpr);
}
return parRpr;
}
use of org.docx4j.wml.ParaRPr in project TranskribusCore by Transkribus.
the class DocxBuilder method createIt.
public static P createIt() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
P p = wmlObjectFactory.createP();
// Create object for pPr
PPr ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
// Create object for rPr
ParaRPr pararpr = wmlObjectFactory.createParaRPr();
ppr.setRPr(pararpr);
// Create object for u
U u = wmlObjectFactory.createU();
pararpr.setU(u);
u.setVal(org.docx4j.wml.UnderlineEnumeration.SINGLE);
// Create object for lang
CTLanguage language = wmlObjectFactory.createCTLanguage();
pararpr.setLang(language);
language.setVal("en-AU");
// Create object for jc
Jc jc = wmlObjectFactory.createJc();
ppr.setJc(jc);
jc.setVal(org.docx4j.wml.JcEnumeration.CENTER);
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add(r);
// Create object for rPr
RPr rpr = wmlObjectFactory.createRPr();
r.setRPr(rpr);
// Create object for u
U u2 = wmlObjectFactory.createU();
rpr.setU(u2);
u2.setVal(org.docx4j.wml.UnderlineEnumeration.SINGLE);
// Create object for lang
CTLanguage language2 = wmlObjectFactory.createCTLanguage();
rpr.setLang(language2);
language2.setVal("en-AU");
// Create object for t (wrapped in JAXBElement)
Text text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
r.getContent().add(textWrapped);
text.setValue("Underlined and centred");
return p;
}
use of org.docx4j.wml.ParaRPr in project docx4j-template by vindell.
the class Docx4J_例子2 method createHyperlink.
public void createHyperlink(WordprocessingMLPackage wordMLPackage, MainDocumentPart t, ObjectFactory factory, P paragraph, String url, String value, String fontName, String fontSize, JcEnumeration jcEnumeration) throws Exception {
org.docx4j.relationships.ObjectFactory reFactory = new org.docx4j.relationships.ObjectFactory();
org.docx4j.relationships.Relationship rel = reFactory.createRelationship();
rel.setType(Namespaces.HYPERLINK);
rel.setTarget(url);
rel.setTargetMode("External");
t.getRelationshipsPart().addRelationship(rel);
StringBuffer sb = new StringBuffer();
// addRelationship sets the rel's @Id
sb.append("<w:hyperlink r:id=\"");
sb.append(rel.getId());
sb.append("\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ");
sb.append("xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" >");
sb.append("<w:r><w:rPr><w:rStyle w:val=\"Hyperlink\" />");
sb.append("<w:rFonts w:ascii=\"");
sb.append(fontName);
sb.append("\" w:hAnsi=\"");
sb.append(fontName);
sb.append("\" w:eastAsia=\"");
sb.append(fontName);
sb.append("\" w:hint=\"eastAsia\"/>");
sb.append("<w:sz w:val=\"");
sb.append(fontSize);
sb.append("\"/><w:szCs w:val=\"");
sb.append(fontSize);
sb.append("\"/></w:rPr><w:t>");
sb.append(value);
sb.append("</w:t></w:r></w:hyperlink>");
Hyperlink link = (Hyperlink) XmlUtils.unmarshalString(sb.toString());
paragraph.getContent().add(link);
setParagraphSpacing(factory, paragraph, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
PPr ppr = paragraph.getPPr();
if (ppr == null) {
ppr = factory.createPPr();
}
RFonts fonts = new RFonts();
fonts.setAscii("微软雅黑");
fonts.setHAnsi("微软雅黑");
fonts.setEastAsia("微软雅黑");
fonts.setHint(STHint.EAST_ASIA);
ParaRPr rpr = new ParaRPr();
rpr.setRFonts(fonts);
ppr.setRPr(rpr);
paragraph.setPPr(ppr);
}
use of org.docx4j.wml.ParaRPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setParaVanish.
public void setParaVanish(PPr ppr, boolean isVanish) {
ParaRPr parRpr = getParaRPr(ppr);
BooleanDefaultTrue vanish = parRpr.getVanish();
if (vanish != null) {
vanish.setVal(isVanish);
} else {
vanish = new BooleanDefaultTrue();
parRpr.setVanish(vanish);
vanish.setVal(isVanish);
}
}
Aggregations