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

Save as html

1 Answer 79 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 28 Feb 2017, 02:01 PM

Hi,

is it possible to save a Text as html without classes? I just saved the word "TEST" in bold and this comes out:

 

TEST

;height:;overflow-y:auto;'>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled</title><style type="text/css">
p { margin-top: 0px;margin-bottom: 10px;line-height: 1.14999997615814; }
body { font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px; }
.TableNormal { telerik-style-type: table;telerik-style-name: TableNormal;border-collapse: collapse; }
.TableGrid { telerik-style-type: table;telerik-style-name: TableGrid;telerik-based-style-name: TableNormal;margin-bottom: 0px;line-height: 1;border-left: 1px solid #000000;border-top: 1px solid #000000;border-right: 1px solid #000000;border-bottom: 1px solid #000000;border-collapse: collapse; }
.Normal { telerik-style-type: paragraph;telerik-style-name: Normal;font-family: 'Calibri';font-size: 14.6666669845581px;border-collapse: collapse; }
.Heading1 { telerik-style-type: paragraph;telerik-style-name: Heading1;telerik-based-style-name: Normal;telerik-linked-style-name: Heading1Char;font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 32px;margin-bottom: 0px;border-collapse: collapse; }
.Heading1Char { telerik-style-type: character;telerik-style-name: Heading1Char;telerik-linked-style-name: Heading1;font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 32px;margin-bottom: 0px;border-collapse: collapse; }
.Heading2 { telerik-style-type: paragraph;telerik-style-name: Heading2;telerik-linked-style-name: Heading2Char;font-family: 'Calibri';font-weight: bold;font-size: 21.3333339691162px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading2Char { telerik-style-type: character;telerik-style-name: Heading2Char;telerik-linked-style-name: Heading2;font-family: 'Calibri';font-weight: bold;font-size: 21.3333339691162px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading3 { telerik-style-type: paragraph;telerik-style-name: Heading3;telerik-linked-style-name: Heading3Char;font-family: 'Calibri';font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading3Char { telerik-style-type: character;telerik-style-name: Heading3Char;telerik-linked-style-name: Heading3;font-family: 'Calibri';font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading4 { telerik-style-type: paragraph;telerik-style-name: Heading4;telerik-based-style-name: Normal;telerik-linked-style-name: Heading4Char;font-style: Italic;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading4Char { telerik-style-type: character;telerik-style-name: Heading4Char;telerik-linked-style-name: Heading4;font-style: Italic;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading5 { telerik-style-type: paragraph;telerik-style-name: Heading5;telerik-based-style-name: Normal;telerik-linked-style-name: Heading5Char;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading5Char { telerik-style-type: character;telerik-style-name: Heading5Char;telerik-linked-style-name: Heading5;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading6 { telerik-style-type: paragraph;telerik-style-name: Heading6;telerik-based-style-name: Normal;telerik-linked-style-name: Heading6Char;font-style: Italic;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading6Char { telerik-style-type: character;telerik-style-name: Heading6Char;telerik-linked-style-name: Heading6;font-style: Italic;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading7 { telerik-style-type: paragraph;telerik-style-name: Heading7;telerik-based-style-name: Normal;telerik-linked-style-name: Heading7Char;font-style: Italic;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading7Char { telerik-style-type: character;telerik-style-name: Heading7Char;telerik-linked-style-name: Heading7;font-style: Italic;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading8 { telerik-style-type: paragraph;telerik-style-name: Heading8;telerik-based-style-name: Normal;telerik-linked-style-name: Heading8Char;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading8Char { telerik-style-type: character;telerik-style-name: Heading8Char;telerik-linked-style-name: Heading8;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading9 { telerik-style-type: paragraph;telerik-style-name: Heading9;telerik-based-style-name: Normal;telerik-linked-style-name: Heading9Char;font-style: Italic;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Heading9Char { telerik-style-type: character;telerik-style-name: Heading9Char;telerik-linked-style-name: Heading9;font-style: Italic;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px;border-collapse: collapse; }
.Caption { telerik-style-type: paragraph;telerik-style-name: Caption;telerik-based-style-name: Normal;font-family: 'Calibri';font-weight: bold;font-size: 12px;color: #4F81BD;line-height: 1;border-collapse: collapse; }
.FootnoteReference { telerik-style-type: character;telerik-style-name: FootnoteReference;border-collapse: collapse; }
.FootnoteText { telerik-style-type: paragraph;telerik-style-name: FootnoteText;telerik-linked-style-name: FootnoteTextChar;font-size: 13.3333333333333px;margin-bottom: 0px;line-height: 1;border-collapse: collapse; }
.FootnoteTextChar { telerik-style-type: character;telerik-style-name: FootnoteTextChar;telerik-linked-style-name: FootnoteText;font-size: 13.3333333333333px;margin-bottom: 0px;line-height: 1;border-collapse: collapse; }
.EndnoteReference { telerik-style-type: character;telerik-style-name: EndnoteReference;border-collapse: collapse; }
.EndnoteText { telerik-style-type: paragraph;telerik-style-name: EndnoteText;telerik-linked-style-name: EndnoteTextChar;font-size: 13.3333333333333px;margin-bottom: 0px;line-height: 1;border-collapse: collapse; }
.EndnoteTextChar { telerik-style-type: character;telerik-style-name: EndnoteTextChar;telerik-linked-style-name: EndnoteText;font-size: 13.3333333333333px;margin-bottom: 0px;line-height: 1;border-collapse: collapse; }
.TOC1 { telerik-style-type: paragraph;telerik-style-name: TOC1;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;border-collapse: collapse; }
.TOC2 { telerik-style-type: paragraph;telerik-style-name: TOC2;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 14.6666669845581px;border-collapse: collapse; }
.TOC3 { telerik-style-type: paragraph;telerik-style-name: TOC3;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 29.3333339691162px;border-collapse: collapse; }
.TOC4 { telerik-style-type: paragraph;telerik-style-name: TOC4;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 44.0000009536743px;border-collapse: collapse; }
.TOC5 { telerik-style-type: paragraph;telerik-style-name: TOC5;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 58.6666679382324px;border-collapse: collapse; }
.TOC6 { telerik-style-type: paragraph;telerik-style-name: TOC6;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 73.3333349227905px;border-collapse: collapse; }
.TOC7 { telerik-style-type: paragraph;telerik-style-name: TOC7;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 88.0000019073486px;border-collapse: collapse; }
.TOC8 { telerik-style-type: paragraph;telerik-style-name: TOC8;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 102.666668891907px;border-collapse: collapse; }
.TOC9 { telerik-style-type: paragraph;telerik-style-name: TOC9;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 117.333335876465px;border-collapse: collapse; }
.TableofFigures { telerik-style-type: paragraph;telerik-style-name: TableofFigures;telerik-based-style-name: Normal;margin-bottom: 0px;border-collapse: collapse; }
.Hyperlink { telerik-style-type: character;telerik-style-name: Hyperlink;color: #0000FF;text-decoration: underline;border-collapse: collapse; }
.Title { telerik-style-type: paragraph;telerik-style-name: Title;font-family: 'Calibri';font-size: 37.3333320617676px;color: #093367;margin-left: 0px;text-align: left;border-collapse: collapse; }
.TOCHeader { telerik-style-type: paragraph;telerik-style-name: TOCHeader;font-family: 'Calibri';font-size: 21.3333339691162px;color: #74A6E2;border-collapse: collapse; }
.p_E2968D9D { telerik-style-type: local; }
.s_6C8EFA9D { telerik-style-type: local;font-weight: bold; }
.s_E2968D9D { telerik-style-type: local; } </style></head><body>

TEST

<p ><span><font weight="bold">TEST</font></span><span class="s_E2968D9D"></span></p>
</body></html>

Is it possible to save the Text without classes?

Thanks

Rene

 

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 02 Mar 2017, 02:51 PM
Hi Rene,

You can achieve the desired behavior using the settings of the HtmlFormatProvider. The possible options are described in the Import/Export Settings article.

To completely remove all the styles from the exported document, you can apply the following settings:
HtmlFormatProvider provider = new HtmlFormatProvider();
HtmlExportSettings exportSettings = new HtmlExportSettings();
exportSettings.ExportBoldAsStrong = true;
exportSettings.ExportItalicAsEm = true;
exportSettings.ExportFontStylesAsTags = true;
exportSettings.ExportHeadingsAsTags = true;
exportSettings.ExportStyleMetadata = false;
exportSettings.StylesExportMode = StylesExportMode.Inline;
exportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
exportSettings.ExportEmptyDocumentAsEmptyString = true;
exportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;
provider.ExportSettings = exportSettings;

Hope this is helpful.

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.
Tags
RichTextBox
Asked by
Rene
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or