Search in sources :

Example 1 with ParaRPr

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;
}
Also used : ParaRPr(org.docx4j.wml.ParaRPr)

Example 2 with ParaRPr

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;
}
Also used : Text(org.docx4j.wml.Text) P(org.docx4j.wml.P) CTLanguage(org.docx4j.wml.CTLanguage) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) U(org.docx4j.wml.U) RPr(org.docx4j.wml.RPr) ParaRPr(org.docx4j.wml.ParaRPr) ParaRPr(org.docx4j.wml.ParaRPr) Jc(org.docx4j.wml.Jc)

Example 3 with ParaRPr

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);
}
Also used : PPr(org.docx4j.wml.PPr) ObjectFactory(org.docx4j.wml.ObjectFactory) Relationship(org.docx4j.relationships.Relationship) ParaRPr(org.docx4j.wml.ParaRPr) RFonts(org.docx4j.wml.RFonts) Hyperlink(org.docx4j.wml.P.Hyperlink)

Example 4 with ParaRPr

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);
    }
}
Also used : ParaRPr(org.docx4j.wml.ParaRPr) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Aggregations

ParaRPr (org.docx4j.wml.ParaRPr)4 PPr (org.docx4j.wml.PPr)2 Relationship (org.docx4j.relationships.Relationship)1 BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)1 CTLanguage (org.docx4j.wml.CTLanguage)1 Jc (org.docx4j.wml.Jc)1 ObjectFactory (org.docx4j.wml.ObjectFactory)1 P (org.docx4j.wml.P)1 Hyperlink (org.docx4j.wml.P.Hyperlink)1 R (org.docx4j.wml.R)1 RFonts (org.docx4j.wml.RFonts)1 RPr (org.docx4j.wml.RPr)1 Text (org.docx4j.wml.Text)1 U (org.docx4j.wml.U)1