This is a migrated thread and some comments may be shown as answers.

HtmlFormatProvider and css

2 Answers 305 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 12 May 2017, 03:47 PM

This may be a long-shot as I don't see it documented anywhere, but can I omit the style tag but still trigger the CssClassExporting event. What I need is to pull the extracted styles into a separate css file. I can parse the files manually if need be, but if there is some combination of configuration options I'm missing here please correct me.  Here is what i have at the moment.

 

HtmlFormatProvider provider = new HtmlFormatProvider();            

provider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;          

provider.ExportSettings.StylesExportMode = StylesExportMode.Classes;                      

provider.ExportSettings.SpanExportMode = SpanExportMode.DefaultBehavior;                         

provider.ExportSettings.ExportStyleMetadata = true;          

// Dont export the document styles

provider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;             

// Export font style as style rather than tag          

provider.ExportSettings.ExportFontStylesAsTags = false;             

// Only create styles which need be             

provider.ExportSettings.ExportLocalOrStyleValueSource = true;             

provider.ExportSettings.CssClassExporting += ExportSettings_CssClassExporting;             

var data = provider.Export(RadDocument);             

2 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 17 May 2017, 12:31 PM
Hello Doug,

The HtmlFormatProvider of RadRichTextBox doesn't expose a similar functionality. The CssClassExporting event is triggered only when StyleRepositoryExportMode is set to ExportStylesAsCssClasses. With that said, what I can suggest you is to parse the produced from the Export() method HTML string and extract the classes as desired.

Regards,
Tanya
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Doug
Top achievements
Rank 1
answered on 17 May 2017, 12:33 PM
Pretty much as I expected, thank you Tanya.
Tags
RichTextBox
Asked by
Doug
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Doug
Top achievements
Rank 1
Share this question
or