Wrap all text in font/size

Hi there,

When using your Rich Text Editor, we have users who will start typing straight away, then start changing fonts/sizes.

When they then export the field value to 3rd parties (eg extract to other websites) we are finding that the initial text isn't given the default font/size, and so renders in unexpected ways depending on the site it is passed to.

Eg, it is quite common to get something like this

Image_9695_1694404340196

"< p >Here is some text< /p >< p >< span style="font-family: Impact, Charcoal, sans-serif;" >Now here is some other stuff in a different font< /span >< /p >< p >< span style="font-size: 20px;" >And here is something in a different text size< /span >< /p >< p >< span style="font-size: 14px;" >and when its extracted, this line should match the first but it can be different depending on the website it goes to< /span >< /p >"


How can we get the to have the font and size from the very first moment the user starts typing?

Than


1 Reply

GD Gokulraj Devarajan Syncfusion Team September 12, 2023 07:48 AM UTC

Hi Stuart,

We have validated your query on "How to set default font size and font family to the Exported content". You can wrap a div with font family, and font size to the Rich Text Editor Component Value property to get consistent styling of the Exported content. We have made a sample to demonstrate this. In the sample, with the click of a button we have wrapped the Value property of the Rich Text Editor Component with the div of font size and font family. Please find the code snippet and sample for your reference.

Code Snippet:

```

    private void HandleEditorValue ()

    {

        if (!this.richTextEditorRef.Value.StartsWith("<div style=\"font-family:\"Segoe UI\",\"Tahoma\",\"Geneva\",\"Verdana\",sans-serif; \"font-sizeof:'11pt'; \"\">") || !this.richTextEditorRef.Value.EndsWith("</div>"))

        {

            // Wrap the content in a <div> tag

            exportEditorValue = "<div style=\"font-family:\"Segoe UI\",\"Tahoma\",\"Geneva\",\"Verdana\",sans-serif; \"font-sizeof:'11pt'; \"\">" + this.richTextEditorRef.Value + "</div>";

        }

    }

```


Regards

Gokulraj Devarajan


Attachment: RTE_Setting_Default_Font_size_for_Exported_content_892b826.zip

Loader.
Up arrow icon