Editor on both mobile and asp.net core

I'm trying to use the SFRichTextEditor on both website and on the mobile app.  

I'm trying to do that convert to RTF to html thing and it works sometimes.  
But the formatting seems to get screwed up when I go from editing on Web to editing on Mobile.

Both controls are SyncFusion and it would seem like it would share a format.

Is there an easier way to do this?  

thank you,

Gene

7 Replies 1 reply marked as answer

DS Devaraj Sekar Syncfusion Team August 17, 2020 10:17 AM UTC

Hi Gene,  
Thank you for contacting Syncfusion support.  
On analyzing further with the provided information, we suspect that the mentioned issue would be due to the converted Html string from RTF. We requesting you to provide more detailed information about the issue reproducing scenario, design layout or RTF text used for conversion (html converted text any of the data), which will be helpful for us provide a prompt solution at earliest.  For more information regarding RTF to Html, please refer following link
https://help.syncfusion.com/xamarin/rich-text-editor/loading-and-saving-rtf-content 
(Note: We request you to not use the styles in head tag of Html content. We are allowing <body> content alone inside RTE-Source due to security and prevention XSS attack. So, the styles will not be applied when it is in head tag.  We suggest to apply the style in-line instead of global style to preserve the format.)  
Regards,  
Devaraj S  



GA Gene Allen August 17, 2020 06:31 PM UTC

Thank you Devaraj,

I remember the problem now.  I'm getting an exception when trying to convert RFTtoHtml on the bolded line.

        string RTFToHtml(string rtf)
        {
            var rtfStream = new MemoryStream();
            var writer = new StreamWriter(rtfStream, Encoding.UTF8);
            writer.Write(rtf);
            writer.Flush();
            rtfStream.Seek(0, SeekOrigin.Begin);
            rtfStream.Position = 0;

            WordDocument doc = new WordDocument(rtfStream, Syncfusion.DocIO.FormatType.Rtf);
            writer.Close();
            HTMLExport export = new HTMLExport();
            MemoryStream htmlStream = new MemoryStream();
            // Saving the Word document as RTF
            export.SaveAsXhtml(doc, htmlStream, Encoding.UTF8);
            doc.Close();
            htmlStream.Position = 0;
            // Loading equivalent HTML obtained from DocIO
            string html = IgnoreVoidElementsInHTML(System.Text.Encoding.UTF8.GetString(htmlStream.ToArray()));
            htmlStream.Dispose();
            return html;
        }




Hoping that my version was out of date, I upgrades to 18.2.
No joy...same exception.





DS Devaraj Sekar Syncfusion Team August 18, 2020 10:47 AM UTC

Hi Gene,  
Thank you for the update.  
We have tried to reproduce the issue , but it works properly . We have shared the sample that we tried at our end which can be downloaded from the below link.  
We suspect that the issue might be due to RTF string. So, we request you to share the RTF string using at your sample,  which will be helpful for us to provide a prompt solution at earliest.  
Please refer the below mentioned UG link for detailed information about Loading and Saving RTF content in SfRichTextEditor control.  
Regards,  
Devaraj S  



GA Gene Allen August 18, 2020 03:51 PM UTC

Thank you Devaraj,

I included a screenshot of the RTF I'm using.  

but I've also updated the code to hardcode the variable and posted it here:

        string RTFToHtml(string rtf)
        {
            rtf = "blah blah  \n\n3rd blah  \n4th blah \nwhy am I losing new lines? ";
            var rtfStream = new MemoryStream();
            var writer = new StreamWriter(rtfStream, Encoding.UTF8);
            writer.Write(rtf);
            writer.Flush();
            rtfStream.Seek(0, SeekOrigin.Begin);
            rtfStream.Position = 0;

            WordDocument doc = new WordDocument(rtfStream, Syncfusion.DocIO.FormatType.Rtf);
            writer.Close();
            HTMLExport export = new HTMLExport();
            MemoryStream htmlStream = new MemoryStream();
            // Saving the Word document as RTF
            export.SaveAsXhtml(doc, htmlStream, Encoding.UTF8);
            doc.Close();
            htmlStream.Position = 0;
            // Loading equivalent HTML obtained from DocIO
            string html = IgnoreVoidElementsInHTML(System.Text.Encoding.UTF8.GetString(htmlStream.ToArray()));
            htmlStream.Dispose();
            return html;
        }



DS Devaraj Sekar Syncfusion Team August 19, 2020 04:25 PM UTC

Hi Gene,    
 
Thank you for the update.  
 
On analyzing further with the provided information, we have found that the provided string is not valid RTF string and it is a plain string. We have checked in MS Word, the provided text is considered as plain text (.txt) file and it is not considered as RTF file. We request you to modify the RTF string used at the design level. 
 
Kindly let us know if you require further assistance.  
 
Regards,  
 
Devaraj S 



GA Gene Allen August 20, 2020 04:42 PM UTC

Thank you Devaraj,

Turns out I was overthinking the whole thing, I think it was the RichTextEditor part.  All I needed to do was keep everything in HTML.

thank you again.

Gene


DS Devaraj Sekar Syncfusion Team August 24, 2020 03:06 AM UTC

Hi Gene, 
  
Thank you for the update. 
  
Yes, we can use HtmlText property and Text property to insert content in SfRichTextEditor control. SfRichTextEditor does not have direct support to add RTF content in the editor. However, it can be achieved using SfDocIO control support. 
  
Please refer the below mentioned UG link for detailed information. 
 
Kindly let us know if you require further assistance. 
  
Regards, 
Devaraj S 
 


Marked as answer
Loader.
Up arrow icon