Page 1 of 1

Failure in converting XHTML string to list<WML objects>

PostPosted: Thu Apr 02, 2015 8:38 pm
by mmshabeer
Hi,

Recently upgraded docx4j version from 2.8.0 to 3.2.1

Rich content needs to inserted in Word document.

Used :

Code: Select all
wordMLPackage.getMainDocumentPart().getContent() .addAll(XHTMLImporter.convert(body, null, wordMLPackage));


since 'convert' method changed in latest version, what is the equivalent to get list of wmi objects?

Tried the following snippet:

Code: Select all
// Run time value
String body ="<html><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px;">Word template test</span></font></html>";

XHTMLImporter importer = new XHTMLImporterImpl(wordMLPackage);
wordMLPackage.getMainDocumentPart().getContent().addAll(importer.convert(body, null));


but formatting is not retained.

Appreciate help on this.

Thanks.