CssStyleSheetType Enumeration |
Specifies how CSS (Cascading Style Sheet) styles are exported to HTML.
Namespace:
Aspose.Words.Saving
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntaxpublic enum CssStyleSheetType
Public Enumeration CssStyleSheetType
public enum class CssStyleSheetType
Members
| Member name | Value | Description |
---|
| Inline | 0 |
CSS styles are written inline (as a value of the style attribute on every element).
|
| Embedded | 1 |
CSS styles are written separately from the content in a style sheet embedded in the HTML file.
|
| External | 2 |
CSS styles are written separately from the content in a style sheet in an external file.
The HTML file links the style sheet.
|
Remarks
ExamplesShows how to work with CSS stylesheets that may be created along with Html documents.
public void CssSavingCallback()
{
Document doc = new Document(MyDir + "Rendering.docx");
HtmlSaveOptions options = new HtmlSaveOptions();
options.CssStyleSheetType = CssStyleSheetType.External;
options.CssStyleSheetFileName = ArtifactsDir + "SavingCallback.CssSavingCallback.css";
options.CssSavingCallback =
new CustomCssSavingCallback(ArtifactsDir + "SavingCallback.CssSavingCallback.css", true, false);
doc.Save(ArtifactsDir + "SavingCallback.CssSavingCallback.html", options);
}
private class CustomCssSavingCallback : ICssSavingCallback
{
public CustomCssSavingCallback(string cssDocFilename, bool isExportNeeded, bool keepCssStreamOpen)
{
mCssTextFileName = cssDocFilename;
mIsExportNeeded = isExportNeeded;
mKeepCssStreamOpen = keepCssStreamOpen;
}
public void CssSaving(CssSavingArgs args)
{
args.CssStream = new FileStream(mCssTextFileName, FileMode.Create);
Assert.True(args.CssStream.CanWrite);
args.IsExportNeeded = mIsExportNeeded;
args.KeepCssStreamOpen = mKeepCssStreamOpen;
Assert.True(args.Document.OriginalFileName.EndsWith("Rendering.docx"));
}
private readonly string mCssTextFileName;
private readonly bool mIsExportNeeded;
private readonly bool mKeepCssStreamOpen;
}
See Also