HtmlSaveOptions.CssStyleSheetFileName

HtmlSaveOptions CssStyleSheetFileName property. Specifies the path and the name of the Cascading Style Sheet CSS file written when a document is exported to HTML. Default is an empty string.

HtmlSaveOptions.CssStyleSheetFileName property

Specifies the path and the name of the Cascading Style Sheet (CSS) file written when a document is exported to HTML. Default is an empty string.

public string CssStyleSheetFileName { get; set; }

Remarks

This property has effect only when saving a document to HTML format and external CSS style sheet is requested using CssStyleSheetType.

If this property is empty, the CSS file will be saved into the same folder and with the same name as the HTML document but with the “.css” extension.

If only path but no file name is specified in this property, the CSS file will be saved into the specified folder and will have the same name as the HTML document but with the “.css” extension.

If the folder specified by this property doesn’t exist, it will be created automatically before the CSS file is saved.

Another way to specify a folder where external CSS file is saved is to use ResourceFolder.

Examples

Shows how to specify a prefix which is added to all CSS class names.

HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
htmlSaveOptions.CssClassNamePrefix = "mycss_";
htmlSaveOptions.CssStyleSheetType = HtmlCssStyleSheetType.External;
htmlSaveOptions.CssStyleSheetFileName = "my_styles.css";

Converter.Create()
    .From(MyDir + "Simple.docx")
    .To(ArtifactsDir + "HtmlSaveOptions.CssClassNamePrefix.html", htmlSaveOptions)
    .Execute();

See Also