Page 1 of 1

How to set font style and size for addAltChunk

PostPosted: Sat Jun 21, 2014 6:00 am
by david.zhaowl
Hi everyone,

I can't find a way to set the font style and size for the word paragraphs and runs converted from some XHTML text.
Code: Select all
getMainDocumentPart().addAltChunk(AltChunkType.Xhtml, xhtml.getBytes(), cell);
.

For sure I could do this after convertAltChunks() by going to target word elements and then set font, but I think there should be a smarter way I didn't find.

Any help is appreciated. Thanks.

David Z.

Re: How to set font style and size for addAltChunk

PostPosted: Tue Jun 24, 2014 10:08 pm
by jason
Regarding the font itself, docx4j ImportXHTML supports mapping a CSS font to a w:rFonts object; see lines 235-280 of https://github.com/plutext/docx4j-Impor ... rImpl.java

However, this is not currently exposed in altChunk processing (which uses docx4j ImportXHTML under the covers).

Regarding font size, bold italic etc, you should be able to set those via CSS (@style attribute)