Equivalent HtmlSaveOptions with document.ToString(SaveFormat.Html)

Hi, I am new to Aspose so I saw that document.ToString(SaveFormat.Html) can convert Docx to Html but it doesn’t preserve some style, so I would like to use HtmlSaveOptions instead, but it become worse. Can you share what is the setting you use for document.ToString(SaveFormat.Html), so I can apply the same for HtmlSaveOptions and tweak around to find the best one suited my task?
Regards,
James

@JamesNguyen I think your question is already answered in another your thread:
https://forum.aspose.com/t/docx-to-html-and-back-to-docx-is-losing-format/278922/4

Hi @alexey.noskov thanks for your quick answer, but I saw that the HtmlSaveOptions has some property like ExportPageMargins which I would like to use, that is why I want to replicate the settings you use in document.ToString(SaveFormat.Html) and then tweak around to find the best one suited my task?
Regards,
James

@JamesNguyen When Node.ToString is called with SaveFormat.Html the following HtmlSaveOptions are used:

HtmlSaveOptions htmlOptions = new HtmlSaveOptions();
// External resources are disabled by default.
htmlOptions.ExportImagesAsBase64 = true;
htmlOptions.CssStyleSheetType = CssStyleSheetType.Inline;
htmlOptions.ExportFontResources = false;
htmlOptions.ExportRoundtripInformation = false;

Thanks again for your quick reply @alexey.noskov , much appreciated it. I will play with it and let you know if I need anymore help.
Regards,
James

1 Like

Hi @alexey.noskov sorry to bother you again, I tried above and compare with the HTML generated by document.ToString(SaveFormat.Html) and they are a bit different. Can you help to check whether any setting you forget by any chance?
Regards,
James

@JamesNguyen Could you please attach your input document here for testing? We will check it and provide you more information.

Hi @alexey.noskov these are the files I used to test
Test 1.docx (43.0 KB)

Test 2.docx (76.6 KB)

@JamesNguyen You are right, z-index attribute of shapes in the HTML produced using Document.ToString method is always zero.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26572

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks @alexey.noskov so even when our company already bought the license, it does not the same with access to Paid Support Services, right? How can we have that support?
BTW, do you have HtmlSaveOptions setting which will return same result as Document.ToString?

@JamesNguyen HTML produced with the provided HtmlSaveOptions produces the same output as Document.ToString, but for some reason ZOrder of shapes is not updated upon using Document.ToString so we have logged WORDSNET-26572 issue.

Yes, Paid Support Services is a separate service and should be purchased additionally.

Thanks again @alexey.noskov, much appreciated your quick action as always :slight_smile:

1 Like