I am currently using DocIO to convert a word document to a html string.
I want to know if there is a way I can customize the output of the css in html string to be inline css?
I've included a screenshot of my code for reference.
Regards
Hi Kuan,
Yes. It is feasible to customize the output of the css in html string to be
inline css.
To achieve your requirement, we have suggested you to set the HtmlExportCssStyleSheetType
property as Inline. Please refer the below highlighted code snippet,
|
WordDocument document = new WordDocument(stream, Syncfusion.DocIO.FormatType.Docx); //Set the style sheet type. document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.Inline; MemoryStream ms = new MemoryStream(); document.Save(ms, Syncfusion.DocIO.FormatType.Html); document.Close(); ms.Position = 0; StreamReader reader = new StreamReader(ms); htmlStringText = reader.ReadToEnd(); ms.Dispose(); reader.Dispose(); |
Please refer our UG documentation link to know more about customizing the Word document to HTML,
https://help.syncfusion.com/file-formats/docio/html#customizing-the-word-to-html-conversion
Regards,
Suriya Balamurugan.
If this post is helpful, please consider Accepting it as the solution so
that other members can locate it more quickly.
I've tried using the solution you suggested and inside the html string that was produced, there are still CSS information which are not inline ( I've included a screenshot of the CSS information below ). Is there anyway that information can also be inline.
What I am trying to accomplish here is Saving the information from Rich Text Editor to a word document. But as far as I know saving into a word document from html doesn't support internal CSS. Because of that I am trying to get as much CSS information I can into inline format so that the format information will be there when I convert into a word document.
If there is a way to include internal CSS styles when converting to a word document. Please also provide an example for it.
Thanks
Hi Kuan,
Sorry for the inconvenience.
Currently DocIO doesn’t have full-fledged support to preserve styles as inline
style in Word document to HTML conversion. We have already logged this
requirement as a feature request in our database. We don’t have any immediate
plans to implement this feature. We will implement this feature in any of our upcoming
releases and will let you know once this feature is implemented.
The status of this feature can be tracked through the below
link:
https://www.syncfusion.com/feedback/3059/export-word-documents-to-html-with-inline-css
To consider your scenario as first priority while implement this feature, kindly
share your input html (which passing to RTE). If you have any confidential data
in your input document, please replace with some dummy data and provide us the
same.
Regards,
Suriya Balamurugan.