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

Find and edit all bullets on document

2 Answers 85 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Ing. Jesus Manuel
Top achievements
Rank 1
Ing. Jesus Manuel asked on 08 Mar 2017, 11:53 PM

Hi, I have a problem with a document, here is what it's going on:

I copy some text from MS Word (THIS TEXT HAS SOME BULLETS) and paste it to the richtexteditor, then I save the content of the document into the database, in a byte array field (this I do it with RTFFORMATPROVIDER).

RtfFormatProvider rtf = new RtfFormatProvider();<br>                string rtfS = rtf.Export(rtfEditor.Document);<br>                byte[] bytes = System.Text.Encoding.Default.GetBytes(rtfS);

Next when I want to show in another screen the document I saved, I show it with RTFFORMATPROVIDER, here what it happens is that I lost the format of the bullets, the bullets are still there but they have a different size and family.

 

<p>byte[] _doc;</p><p>String eTexto = System.Text.Encoding.Default.GetString(_doc);</p><p>RtfFormatProvider rtf = new RtfFormatProvider();<br>                rtfEditor.Document = rtf.Import(eTexto);</p>

 

I know that this is probably because of the way I save the document since the one in MS Word is in .DOC format, and I am saving it in .RTF format.

What I need, is that to find all bullets after the richTextEditor.Import, so I can set the family and size that I want(which is always the same one, TimesNewRoman Size10).

Is there a way to achieve this?

Thanks in advanced.

2 Answers, 1 is accepted

Sort by
0
Ing. Jesus Manuel
Top achievements
Rank 1
answered on 08 Mar 2017, 11:58 PM

Sorry about the double post, didn't see an edit option.

Another thing that can help is to select all the document and apply the family font and font size I want, but can't select the bullets as if they are not part of the document.

0
Hristo
Telerik team
answered on 13 Mar 2017, 03:50 PM
Hello Jesus,

Thank you for writing.

You can iterate the paragraphs and set the desired font size which will affect the bullets. The text settings can be altered by accessing the spans. Please check my code snippet below: 
RadDocument document = this.ImportRtf();
foreach (Paragraph paragraph in document.EnumerateChildrenOfType<Paragraph>())
{
    if (paragraph.ListId != -1)
    {
        paragraph.FontSize = Unit.PointToDip(10);
        foreach (var item in paragraph.Inlines)
        {
            Span sp = item as Span;
            if (sp != null)
            {
                sp.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily("Times New Roman");
                sp.FontSize = Unit.PointToDip(10);
            }
        }
    }
}
 
this.radRichTextEditor1.Document = document;

Additionally, please also check the following documentation article providing additional information on the document elements: http://docs.telerik.com/devtools/winforms/richtexteditor/document-elements/overview.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
RichTextEditor
Asked by
Ing. Jesus Manuel
Top achievements
Rank 1
Answers by
Ing. Jesus Manuel
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or