We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Including a stylesheet with the InsertXHTML method

Thread ID:

Created:

Updated:

Platform:

Replies:

145497 Jun 25,2019 04:39 PM UTC Jun 27,2019 12:41 PM UTC ASP.NET Web Forms 3
loading
Tags: DocIO
David Homer
Asked On June 25, 2019 04:39 PM UTC

Hello,

We are trying to import some XHTML from a HTML editor control (which includes things like TABLEs and DIVs) into a Word document using DocIO.

The TABLEs and DIVs have some class tags assigned that releate to a CSS stylesheet.

We can't find a way to link a CSS stylesheet and putting the StyleSheet code into the XHTML doesn't seem to do anything.

Inline styles do work (see screenshot)... any ideas?


IWParagraph paragraph = section.AddParagraph();
string htmlstring = Resources.Files.source;
section.Body.InsertXHTML(htmlstring);


Resources.Files.source

<html>
    <head>
        <style type="text/css">
            .WarningBox {
                border: solid 1px #AA0000;
                background-color: #FFDDDD;
                padding: 20px;
            }
        </style>
    </head>
    <body>
        <div class="WarningBox">
            Box with CSS style
        </div>
        <div style="border: solid 1px #AA0000; background-color: #FFDDDD; padding: 20px;">
            Box with inline styles
        </div>
    </body>
</html>




Attachment: Styles_2dc81062.zip

Mohanaselvam  Jothi [Syncfusion]
Replied On June 26, 2019 11:11 AM UTC

Hi David,

Thank you for contacting Syncfusion support.

On further analyzing on the given HTML, we have found that the preservation problem occurs due to internal CSS styles used in HTML. Currently DocIO have only support to preserve inline CSS styles in HTML to Word conversion and we doesn’t have support for internal and external CSS style sheet in HTML import. We have already logged this requirement as a feature request in our database. We don’t have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented and it can be tracked through below feedback portal link:
https://www.syncfusion.com/feedback/3059/export-word-documents-to-html-with-inline-css

Please let us know if you have any other questions.

Regards,
Mohanaselvam J


David Homer
Replied On June 26, 2019 11:19 AM UTC

Hello,

Thank you for the reply. This is a very big limitation.

The source code of DocIO appears to support parsing StyleSheets inline though (see screenshot) perhaps it just doesn't work?


Thanks,


Dave


Attachment: AppendCssStyle_88a89203.zip

Mohanaselvam  Jothi [Syncfusion]
Replied On June 27, 2019 12:41 PM UTC

Hi David,

Thank you for your update.

DocIO partially supports the internal CSS stylesheet in HTML to Word conversion. Currently, we doesn’t provide complete support for preserving internal CSS styles in HTML conversions. We will consider your scenario in our feature request and it will be preserved properly once that feature is implemented. As mentioned in our previous update, we don’t have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented.

Please let us know if you have any other questions.


Regards,
Mohanaselvam J 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon