Free Support Forum -

Word to HTML with Aspose Word for Java

Recently we have upgraded to aspose word for java version 2.3.
After that looks like html convert functionality has broken.

I am getting followinig exception while trying to convert

Exception in thread “main” Trying to write multiple DOCTYPE declarations
at com.ctc.wstx.sw.BaseStreamWriter.verifyWriteDTD(
at com.ctc.wstx.sw.BaseStreamWriter.writeDTD(
at com.aspose.words.internal.dv.a(Unknown Source)
at com.aspose.words.ei.b(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at Source)

Following is the sample program I am using to convert:


import com.aspose.words.Document;
import com.aspose.words.SaveFormat;

public class AsTest {
public static void main(String[] args) throws Exception{
String docFile = “C:/test.doc”;
Document srcDoc = new Document(docFile);
// Image paths for the server (local) - aspose.words puts generated image files here.

File theFile = new File(“C:”, “test.html”);
FileOutputStream out = new FileOutputStream(theFile);
srcDoc.getSaveOptions().setHtmlExportImagesFolderAlias(“C:”);, SaveFormat.HTML);



Can you tell me if I need to change the code to get it working?



Thanks for your inquiry. Could you please attach your document here? (only you and Aspose staff can download it) I will try to reproduce this problem and provide you more information.

Best regards.

Please find the attached document I am using with code.



Thanks fro additional information. I can’t reproduce this problem on my side. I use the latest version of Aspose.Words for Java

This version of Aspose.Words is available for download from here.

Best regards.

Hi Alex,

Thanks for reply.
We are using 2.3 and it will not be possible for us to move 2.4 since we need to do addition testing for that.
Can you try to reproduce it in 2.3?


I tried to reproduce this problem on version. But this works fine on my side. Maybe you can provide me additional information about this problem.

Best regards.

Hi, Sunil

Good to see you again:)

The thing is in the StAX library. You are using Woodstox StAX library but Aspose.Words for Java needs in the Sun StAX library. You have to configure your environment so that Aspose.Words will load Sun StAX instead of Woodsotox. Sun StAX is included into Aspose.Words download (jsr173_1.0_api.jar and sjsxp.jar). If you are using jdk 1.6 you don’t need in these jars – the library already included into jdk.

Though library compatibility is not our problem, but we work on this right now. May be starting from the next release this problem will don’t bother ours user any more:)

Best Regards,

Hi Konstantin,

Thanks for the pointer. After replacing woodstox with Sun's StAX word to html started working, but unfortunately our webservice which were written using Axis 2, got broken :(

<span style=“font-size: 12pt; font-family: “Times New Roman”;”>By any chance does any of your customers faced same
issue? And were able to solve this?

Hi, Sunil,

So we have a real library conflict – welcome to the jar hell;)

Probably you had upgraded Woodstox too when you upgraded Aspose.Words to 2.3? May be reverting Woodstox to previous version will fix the problem? (until the next release)

I think so because Aspose.Words _always_ used Sun StAX XML writer for html export and you write that AW 2.2 worked fine in your environment – thus, may be previous version of Woodstox worked exactly as Sun?

Another way (not always applicable) is using different classloaders for those application parts which using Woodstox and Sun StAX appropriately.

Library incompatibility (jar hell) is a common problem in the java environment. Though you the first customer that faced StAX library incompatibility but there was problems with another libraries. We faced cases both with incompatibility of different versions of one library (library from one vendor) and with incompatibility of different libraries (libraries from different vendors) that implements the same standard/interface – like in your case.

By now we were solving the problem by obfuscating ‘ours’ libraries inside the Aspose.Words jar so a user doesn’t need to think about library compatibility. But the Sun StAX library contains a text property files with links to some classes. These text files are ignored by ours ‘old’ obfuscator so we can’t obfuscate the lib.

Right now I’m working on release that will contain the fix of this problem (we will use another obfuscator with even more sophisticated configuration). The schedule of this release is a first half of February.

Best Regards,

Hi Konstantin,

In last version we were using the Asix 1 which I think doesn’t require StAX or worked with Sun’s jar, so everything worked fine.
This time we changed Aspose version and Axis version together which caused whole mess.

If in the next release it will be fixed and it is coming in a month it would be better for us to wait for that.


Hi, Sunil,

You can check how this feature will work in your environment just now. I send to your email corrected jar. This is purely 2.4 version but with StAX and other external libs obfuscated into Aspose.Words jar. Real 2.4.1 release will contain another emprovments. Please inform me if something wrong with the jar.