Can't convert very simple HTML with latest DocIO java

Using the following very simple HTML document:

<html>

  <body>

    <table >

      <tr>

        <td>

          NAME | ADDRESS

        </td>

        <td >

           NAME | TITLE

        </td>

      </tr>

      <tr>

        <td>

          text

        </td>

        <td>

          <div>addressLine1</div>

          <div>zip city</div>

          <div>

            NAME

          </div>

          <div>FULL TITLE</div>

          <br />

          <div>Text

          </div>

          <div>CITY, DATE</div>

            <div>

              Telefon:

            </div>

            <div>+49 30 123456</div>

            <div>

              Fax:

            </div>

            <div>+49 30 123456</div>

          <div>[email protected]</div>

          <div>www.domain.de</div>

        </td>

      </tr>

    </table>

  </body>

</html>



whenever I try to convert this using 

new WordDocument().open(theString, FormatType.Html)

the following exception is thrown:

java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lcom.syncfusion.docio.HTMLConverterImpl$TextFormat; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lcom.syncfusion.docio.HTMLConverterImpl$TextFormat; is in unnamed module of loader 'app')

at com.syncfusion.docio.HTMLConverterImpl.applyDivParagraphFormat(HTMLConverterImpl.java:3436)

at com.syncfusion.docio.HTMLConverterImpl.addNewParagraph(HTMLConverterImpl.java:1656)

at com.syncfusion.docio.HTMLConverterImpl.addNewParagraphToTextBody(HTMLConverterImpl.java:1558)

at com.syncfusion.docio.HTMLConverterImpl.traverseTextWithinTag(HTMLConverterImpl.java:1408)

at com.syncfusion.docio.HTMLConverterImpl.traverseChildNodes(HTMLConverterImpl.java:1352)

at com.syncfusion.docio.HTMLConverterImpl.parseTags(HTMLConverterImpl.java:1759)

at com.syncfusion.docio.HTMLConverterImpl.traverseChildNodes(HTMLConverterImpl.java:1364)

at com.syncfusion.docio.HTMLConverterImpl.parseTableRows(HTMLConverterImpl.java:6042)

at com.syncfusion.docio.HTMLConverterImpl.parseTable(HTMLConverterImpl.java:5887)

at com.syncfusion.docio.HTMLConverterImpl.parseTags(HTMLConverterImpl.java:1779)

at com.syncfusion.docio.HTMLConverterImpl.traverseChildNodes(HTMLConverterImpl.java:1364)

at com.syncfusion.docio.HTMLConverterImpl.appendToTextBody(HTMLConverterImpl.java:495)

at com.syncfusion.docio.WTextBody.insertXHTML(WTextBody.java:272)

at com.syncfusion.docio.WTextBody.insertXHTML(WTextBody.java:256)

at com.syncfusion.docio.WordDocument.openHTML(WordDocument.java:4561)

at com.syncfusion.docio.WordDocument.openInternal(WordDocument.java:4509)

at com.syncfusion.docio.WordDocument.open_Internal(WordDocument.java:4440)

at com.syncfusion.docio.WordDocument.open(WordDocument.java:4435)

at com.syncfusion.ej2.wordprocessor.DocxImporting.convertToDocumentAdv(DocxImporting.java:73)

at com.syncfusion.ej2.wordprocessor.WordProcessorHelper.loadString(WordProcessorHelper.java:206)


5 Replies 1 reply marked as answer

SB Sneha Biju Syncfusion Team March 18, 2024 09:17 AM UTC

Hi Philipp,

We have created an HTML file using the provided HTML code. We have also attempted to convert that created HTML file to DOCX using DocIO – Java, but it is working properly. We have attached a sample with the input HTML file and output DOCX document.

If you are still facing the same issue, please provide us with a reproducible sample and the versions of the jars used so that we can replicate the exact issue on our end.

Regards,
Sneha.


Attachment: Sample_aad8c46e.zip


PE Philipp Eschenbach March 21, 2024 11:21 AM UTC

@Sneha could it be a difference in java versions?



SB Sneha Biju Syncfusion Team March 22, 2024 08:03 AM UTC

Philipp, we have tested the sample in version v24.2.9 as stated in your profile, and it is working fine on our end. We have attached the output DOCX document in the mentioned version v24.2.9 below. We also recommend that you use the latest version to take advantage of our latest bug fixes.

Could you please share the version you used at your end with us so that we can analyze it further and provide you with the appropriate solution?


Attachment: Output_(v24.2.9)_b3984297.docx

Marked as answer

PE Philipp Eschenbach March 22, 2024 10:44 AM UTC

OH MY GOD

we have tested with super old version that is referenced in the docs on how to use WordProcessor with gradle.


this current version works like a charm!



DS Dhanush Sekar Syncfusion Team March 25, 2024 10:44 AM UTC

Thanks for the update! Philipp

We are happy to hear that you found it. We would be happy to assist you as always.



Loader.
Up arrow icon