Hi,
I’m facing an issue while parsing a word document containing tables into HTML.
The following is my code to parse the document :
Document parsedDocument = new Document(file1);
Document document = new Document();
document.appendDocument(parsedDocument, ImportFormatMode.KEEP_SOURCE_FORMATTING);
document.acceptAllRevisions();
document.joinRunsWithSameFormatting();
ByteArrayOutputStream outStream1 = new ByteArrayOutputStream();
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
options.setExportTextInputFormFieldAsText(true);
document.save(outStream1, options);
The steps to reproduce the problems are as follows:
- Open a new word document (.doc format).
- Keep Track Changes on for the document.
- Create a small table with 3 rows and 3 columns.
- Accept all changes.
- Now Delete an entire row, say row 2. (By delete I mean delete all the cells and NOT just the content inside them)
6.Now Add a new column in between, say column 2 and 3. - Now pass this document to Aspose to generate the HTML.
(Note that I have not manually accepted the track changes in the document after deleting the row and adding the column, I intend to do that programmatically.)
Expected Result :
The expected result according to my changes should have been a table with 2 rows and 4 columns.
Actual Result :
In the resulting HTML, the cell which lies on the intersection point of the deleted row and added column ( Row2-Col3 according to my steps) is also part of the result.
Conclusion :
I’ve noticed that if after step6 if I manually accept all changes, the document is parsed correctly.The intersecting cell is both deleted and added at the same time, which is probably causing the issue.
Kindly let me know if I’m doing something wrong or if there are functions to accept each change individually in java.
I have attached the sample document as well as snapshots of the expected and actual results.
Thanks.
Regards,
Siddarth