We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error saving document to HTML using Aspose.Words Java

Minimal Broken page-Template.zip (46.9 KB)
The extension of the attached file can be changed from zip to docx - this is a docx file.
We are currently using Aspose.Words java version 20.1
When saving to HTML using the Java code below, an error is generated.
Deleting almost any single part of the file (it is very small) makes it work.
This is weird. A workaround - if one exists - would be great, and a fix welcome, of course.

  String convertToHTML(File docFile) {
    String htmlDoc = null;
    try {
      InputStream inpStr = new FileInputStream(docFile);
      LoadOptions loadOptions = new LoadOptions(LoadFormat.DOCX, "", null);
      Document inputDoc = new Document(inpStr, loadOptions);
      inputDoc.joinRunsWithSameFormatting(); // html cleanup stage one
      ByteArrayOutputStream outStr = new ByteArrayOutputStream();
      HtmlSaveOptions saveOptions = new HtmlSaveOptions();

      inputDoc.save(outStr, saveOptions);
      htmlDoc = outStr.toString("UTF-8");
    } catch(Exception ex) {
    return htmlDoc;


We have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-21622. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-21622) have been fixed in this Aspose.Words for .NET 21.6 update and this Aspose.Words for Java 21.6 update.