Currently I am doing:
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mp = wordMLPackage.getMainDocumentPart ();
// Sort out the styles.
StyleDefinitionsPart sdp = mp.getStyleDefinitionsPart ();
Map<String, Style> styles = sdp.getKnownStyles ();
Style titleS = styles.get (NORMAL);
if (titleS != null)
{
// Get the rpr.
RPr rpr = titleS.getRPr ();
if (rpr == null)
{
rpr = new RPr ();
titleS.setRPr (rpr);
}
RFonts rf = rpr.getRFonts ();
if (rf == null)
{
rf = new RFonts ();
rpr.setRFonts (rf);
}
rf.setAscii ("Verdana");
}
But it doesn't work. Anyone any idea what I'm missing? I've checked the styles.xml file and it doesn't contain Verdana anywhere, the style for Normal usually winds up looking like this:
- Code: Select all
<w:style w:default="true" w:styleId="Normal" w:type="paragraph"><w:name w:val="Normal"/><w:qFormat/><w:rsid w:val="004A3277"/></w:style>
There doesn't even appear to be any rPr element.
If it's not possible to set the values on the default styles how would I go about adding my own pre-built styles.xml file into the document?
Thanks in advance,
Gary