Incorrect HTML output when converting from Word

aspose_test (1).zip (10.9 KB)

Hi,
We are facing an issue where the styles change during the conversion from Word to HTML. We’ve attached two documents: one in Word format and the other in HTML format.

In the Word document, there is a section labeled ‘3. 3 text’ as ‘outlinetxt2.’ However, in the HTML version, it appears as class=‘outlinetxt3.’

Please note we cannot accept revisions during the conversion.

Could you please advise
Thanks

@jay_wang outlinetxt2 style is applied to the mentioned paragraph as a revision. To get the desired output in HTML, you should accept revisions before saving the document. See the following code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Revisions.AcceptAll();
doc.Save(@"C:\Temp\out.html", new HtmlSaveOptions() { PrettyFormat=true, CssStyleSheetType = CssStyleSheetType.Embedded });

Is there a way to accept all revision and keep the comments and track changes?
Since we want to show customers the same style in Html as in the Doc.

@jay_wang If you would like to produce HTML that looks exactly as the source document in MS Word, you can use HtmlFixed format:

Document doc = new Document(@"C:\Temp\in.docx");

HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.ExportEmbeddedCss = true;
opt.ExportEmbeddedFonts = true;
opt.ExportEmbeddedImages = true;
opt.ExportEmbeddedSvg = true;

doc.Save(@"C:\Temp\out.html", opt);

But please note, that HtmlFixed is designed only for viewing purposes not for editing or further conversion.

@alexey.noskov Thanks, we tried it, the class in the Html got changed, for instance, from outlinetxt to awdiv

We do need them for further processing. Bacially we want the html to has the same style classes and track changes/comments as the Doc.

Is it possible to keep the original classes?

@jay_wang No, unfortunately, there is no way to keep original style names after converting document to HtmlFixed. As I have mentioned the format is designed for viewing purposes only.

@alexey.noskov got it, but is there any other way to accept revisions and keep the comments/changes, without using HtmlFixedSaveOptions ?

@jay_wang I am afraid there is no way to preserve formatting revisions upon exporting to flow HTML. Only insert and delete revisions are supported upon saving to flow HTML format.

got it, thank you so much

1 Like