Converting HTML to Word docx

I’m using Aspose.Words for java version 4.0.3 and this code to save a html document to word document and it works

doc = new Document(input_dir + test.html);
doc.save(output_dir + test.docx);

My questions is there a way to grab the html class information from html elements and convert those class attributes to custom wordstyle names? So instead of the wordstyles on the
html element in the docx file being set to “Normal” I would like to set them to the equivalent to the class attributes values.

Hi
Thanks for your request. The latest version of Aspose.Words automatically does what you need. For example if you have HTML like the following:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <style type="text/css">
        .test {
            font-size: 12pt;
            font-weight: bold;
            margin-bottom: 14pt;
        }
    </style>
</head>
<body>
    <div>
        <p class="test">test</p>
    </div>
</body>
</html>

If you convert this HTML to DOC, the output document will contain a paragraph with style named “test”.
Best regards,

I am using Aspose.Words for Java 4.0.3 when you say latest version are you talking about the beta version that’s coming out by the end of the month? Can you be more specific about the version number?

thanks

Hi
Thanks for your request. Yes, I am talking about 10.0.0 beta version. You can download it from here:
https://releases.aspose.com/words/java
Best regards,