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.

Fri Dec 13, 2024 1:16 am

After upgrading to the latest Spire packages we are receiving the following error when trying to convert a Word file to HTML:

You are saving HTML to a stream and requesting the CSS style sheet to be written into a separate file. In this case you must specify path and name of the CSS file.


Where is the option to specify that the CSS style sheet is written into a separate file?

Axima
 
Posts: 9
Joined: Wed Nov 27, 2013 12:28 am

Fri Dec 13, 2024 7:20 am

Hello,

Thanks for your inquiry.

Please refer to the following code:
Code: Select all
 // Create a new Document object.
            Document document = new Document();

            // Load the Word document from the specified file path.
            document.LoadFromFile(@"..\..\..\..\..\..\..\Data\ToHtmlTemplate.docx");

            // Set the file name for the CSS style sheet that will be used in the HTML export.
            document.HtmlExportOptions.CssStyleSheetFileName = "sample.css";

            // Specify that the CSS style sheet should be external.
            document.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.External;

            // Disable embedding images in the HTML output.
            document.HtmlExportOptions.ImageEmbedded = false;

            // Set the path where the exported HTML file will look for image resources.
            document.HtmlExportOptions.ImagesPath = "Images";

            // Treat text input form fields as plain text instead of form fields.
            document.HtmlExportOptions.IsTextInputFormFieldAsText = true;

            // Save the document as an HTML file with the specified file name and format.
            document.SaveToFile("Sample.html", FileFormat.Html);

            // Release the resources associated with the Document object.
            document.Dispose();


If the above code doesn't help, please provide your Word file for investigation. Thanks.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Fri Dec 20, 2024 9:12 am

Hello,

Hope you are doing well.

Has your issue been solved? Could you please give us some feedback?

I'm looking forward to receiving your feedback soon.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Sun Dec 22, 2024 9:05 pm

Hi Amy,

Yes it was thanks.
We set:

Code: Select all
document.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.Internal;

which resolved the issue.

However I would suggest that this should be the default value, as if you don't set anything it defaults to External and you get the original error.

Axima
 
Posts: 9
Joined: Wed Nov 27, 2013 12:28 am

Mon Dec 23, 2024 3:12 am

Hello,

Thank you for your feedback.

I have relayed your suggestions to our development team. The developers have conducted a comprehensive evaluation immediately. Based on the current usage statistics, a significant number of our clients who use this method tend to export CSS files separately and many customers make secondary modifications to the CSS files. Apologies, but for now, we will continue with the existing default configuration. We will also look into optimizing this based on the proportion of usage in the future.

We greatly appreciate your suggestions and look forward to receiving more feedback from you for our reference in the future.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Mon Dec 23, 2024 3:28 am

Hi Amy,

How do you gather usage statistics?

Axima
 
Posts: 9
Joined: Wed Nov 27, 2013 12:28 am

Mon Dec 23, 2024 5:57 am

Hi Axima,

Thank you for your further inquiry.

Our system logs the concerns, issues, and requirements regarding product features from customers who reach out to us through various communication channels. In order to continuously optimize our products and make every effort to resolve the issues encountered by our customers and meet their needs.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc

cron