We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Converting RTF text to html text to be able to display on Web page

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 = “…”;<o:p></o:p>

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;

}

A post was split to a new topic: RtfStringToDocument for Java