How to convert RTF to HTML using your RichTextBox control?

Posted by: saf_itpro on 16 March 2019, 6:10 am EST

    • Post Options:
    • Link

    Posted 16 March 2019, 6:10 am 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 17 March 2019, 10:28 pm 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, 4:48 am 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 25 March 2019, 11:35 pm EST - Updated 30 September 2022, 12: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, 11:09 am EST

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

Need extra support?

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

Learn More

Forum Channels