Find and edit all bullets on document

3 posts, 0 answers
  1. Ing. Jesus Manuel
    Ing. Jesus Manuel avatar
    16 posts
    Member since:
    Apr 2013

    Posted 08 Mar Link to this post

    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. Ing. Jesus Manuel
    Ing. Jesus Manuel avatar
    16 posts
    Member since:
    Apr 2013

    Posted 08 Mar in reply to Ing. Jesus Manuel Link to this post

    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.

  3. Hristo
    Admin
    Hristo avatar
    1018 posts

    Posted 13 Mar Link to this post

    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.
Back to Top