How to convert RTF to HTML using your RichTextBox control?

Posted by: saf_itpro on 16 March 2019, 3:10 pm EST

    • Post Options:
    • Link

    Posted 16 March 2019, 3:10 pm EST

    The Read and Write Rich Text Format Documents section of your online article https://www.grapecity.com/en/controls/uwp/richtextbox reads: “you can use it to convert RTF to HTML and vice versa.”

    I went through your API document https://help.grapecity.com/componentone/NetHelp/C1worduwp/webframe.html#WordforUWPOverview.html but could not figure out how to do it.

    Question: Could you please provide (or link to an online sample) for converting RTF to HTML in you RichTextBox control? I’m using C# but VB code also be fine.

    NOTE: Before I buy your UWP edition, I must ensure that I can convert RTF to HTML as described in your online document referenced above.

    Thanks…Saf

  • Posted 18 March 2019, 7:28 am EST

    Hi,

    The Word for UWP API uses C1WordDocument for creating a document which can be used for Docx, RTF and Txt formats. However, C1RichTextBox can be used for converting RTF to HTML or vice versa.

    You can verify this by using the “RTFFilter” part of the attached sample (RichTextBoxSamples.zip). Alternatively, you can install the ControlExplorer UWP app from “https://www.microsoft.com/en-us/p/componentone-studio-uwp-edition/9nblggh6cd9j?activetab=pivot:overviewtab” and have a look into the RichTextBox samples under Input and Editing section.

    Also, you can refer “https://help.grapecity.com/componentone/NetHelp/RichTextBoxUWP/webframe.html#Html_Content.html” in order to understand how C1RichTextBox.Html property works.

    Thanks & Regards,

    Basant

    RichTextBoxSamples.zip

  • Posted 25 March 2019, 1:48 pm EST

    Thanks for the response. I opened your RichTextBoxSamples project in Visual Studio 2017 - from the zip file you have provided above . And, when I tried to add your C1.Xaml.UWP package via Nuget, it gave me the following error. Without the C1.UWP package the app does not compile:

    Failed to add reference to ‘C1.UWP.Design’.

    The project targets ‘.NETCore’ while the file reference targets ‘.NETFramework’. This is not a supported scenario.

    What Nuget packages are required for the sample project you have provided in your previous response? Please advise. Thank you.

  • Posted 26 March 2019, 8:35 am EST - Updated 30 September 2022, 9:09 am EST

    Hi,

    For adding Nuget packages, you have to first remove the references for all C1 libraries from main project and then add the corresponding Nuget packages in the main project references. Following Image shows the added Nuget packages:

    Also, I have modified the sample for using Nuget packages and would request you to verify with the attached modified sample (RichTextBoxSamples_Mod.zip).

    Thanks & Regards,

    Basant

    RichTextBoxSamples_Mod.zip

  • Posted 26 March 2019, 8:09 pm EST

    New sample file you attached above worked (thank you). -Saf

  • Posted 17 September 2024, 2:38 am EST

    Hi guys,

    I need the same thing (conversion from RTF to HTML and voca versa) but in in WinUI 3. The provided project in the post does not open under VS2022 17.11.3. It misses the

    RichTextBoxSamplesLib2015
    project.

    Thanks for your help!

    Best regards,

    Louis

  • Posted 19 September 2024, 6:44 am EST

    Hi,

    It seems that you have created a duplicate case on WinUI forum as well. We kindly request you track the following link for further update on this requirement: https://developer.mescius.com/forums/winui-edition/html-editor-control-for-winui

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels