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

How shorten the output string of RtfFormatProvider.Export(radDocument)?

1 Answer 57 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 1
Lukas asked on 31 Jul 2012, 04:30 PM
Dear Telerik team,

I'm facing following problem: in our application there is all over the place the chance to put rich text into a master item. This master item holds RTF strings in data fields. Those master items can theoratically hold an infinite amount of data fields. Technically there is a chance to save on each of these data fields one RTF string. We're using strings instead of documents, because they need less disk space and are faster to handle.

We achieve that with using the RadRichTextBox and the RtfFormatProvider. We double check if there is actual text in the RichTextBox before saving it (converting it with TxtFormatProvider). There is are lots of big texts stored in our DB, but imagine 30% out of ten thousands of records just hold a couple of words. The string, which is generated for standard styles (probably defined in the RtfFormatProvider class) is way bigger than the actual text. And if we save those everytime, maybe half of the disk space used by our application DB is because of those default styles.

Simple demonstration:

private void GenerateEmptyRtf()
{
    var doc = new RadDocument();
    var str = new RtfFormatProvider().Export(doc);
}

Even though the document doesn't hold any content, at all, the string is huge.

I thought already about manually appending and trimming off those styles, everytime I get a RTF string from the DB. But I cannot really provide, that this happens properly (RegExp or similar stuff).

There is absolutely no other way than saving it in the RichTextFormat.

I really hope there is a proper solution. Any help is greatly appreaciated.

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 03 Aug 2012, 02:20 PM
Hello Lukas,

The greatest impact to the size of the exported RTF string is due to the styles that are added to each new document - Heading 1, Heading 2, etc. You could remove unnecessary style definitions from the StyleRepository of the document just after it is created in case they won't be used. Please refer to this forum post answer for more information.

I hope this information helps. Don't hesitate to contact us if you have other questions.

Greetings,
Vasil
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Lukas
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or