Hi, I am wondering if I can do following in Aspose
string htmltxt = ConvertToHtml(string RTF)
Hi, I am wondering if I can do following in Aspose
string htmltxt = ConvertToHtml(string RTF)
Hi there,
Thanks for your inquiry. Yes, you can convert RTF text to Html string using following code example. Please let us know if you have any more queries.
String rtf = "…";
Document doc = RtfStringToDocument(rtf);
String html = doc.ToString(SaveFormat.Html);
private static Document RtfStringToDocument(string rtf)
{
Document doc = null;
// Convert RTF string to byte array.
byte[] rtfBytes = Encoding.UTF8.GetBytes(rtf);
LoadOptions loadoptions = new LoadOptions();
loadoptions.LoadFormat = LoadFormat.Rtf;
// Create stream.
using (MemoryStream rtfStream = new MemoryStream(rtfBytes))
{
// Open document from stream.
doc = new Document(rtfStream, loadoptions);
}
return doc;
}