Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jul 27, 2021 4:01 pm

Hi,

We are seeing the HtmlExportOptions.CssStyleSheetType not really having an effect on the Word ==> HTML conversion. I'm doing it in the following way.

Code: Select all
doc.LoadFromStream(fileToConvert, Spire.Doc.FileFormat.Auto);
doc.HtmlExportOptions.ImageEmbedded = true;
doc.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.Internal;
doc.SaveToStream(stream, Spire.Doc.FileFormat.Html);


The issue is that the converted response HTML is used on the existing HTML page to display the converted document in a dialog and the styles returned with the conversion include the body css { font-family:'Times New Roman'; font-size:1em; } in the <style> element. This conflicts with the overall pages styles and changes the page font everywhere. Do you have any suggestions on how to deal with this?

It's difficult to upload the code as it's part of a WCF service and we use streams. Changing the CssStyleSheetType to External also has no effect.

Thanks.
Kal.

kal.dhami
 
Posts: 7
Joined: Fri Apr 30, 2021 10:15 am

Wed Jul 28, 2021 9:43 am

Hello Kal,

Thanks for your inquiry.
Please add the following code to avoid adding styles for body in the <style> element when converting Word to HTML. If you have further questions, just feel free to contact us.
Code: Select all
            doc.HtmlExportOptions.IsExportDocumentStyles = false;


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Jul 29, 2021 9:14 am

Hi Brian,

That worked like a charm. Thanks for the help.

Kal.

kal.dhami
 
Posts: 7
Joined: Fri Apr 30, 2021 10:15 am

Thu Jul 29, 2021 9:43 am

You are welcome.
If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc