HTML converted to RTF has invalid char appended

When the following code is ran to convert the html string "
· Reason for Referral" to RTF, the RTF comes out “· Reason for Referral”, which is not expected, and appears to be wrong.

This conversion error is causing my program to output RTF that appears corrupted with invalid data and characters. Please let me know if there is a setting that I am missing which will prevent this from happening. This is a critical bug for my software’s current release, that is to go out ASAP.

Thank you,
Jon Ediger

public string HtmlToRtf(string html)
{
    ASPOSE_LicenseHandler.SetLicense();
    string rtf;
    var options = new LoadOptions(LoadFormat.Html, "", "");
    using(var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
    {
        using(var rtfStream = new MemoryStream())
        {
            var doc = new Document(htmlStream, options);

            doc.Save(rtfStream, new RtfSaveOptions
            {
                ExportCompactSize = true, SaveFormat = SaveFormat.Rtf
            });
            rtfStream.Position = 0;
            var sr = new StreamReader(rtfStream);
            rtf = sr.ReadToEnd();
        }
    }
    return rtf;
}

Hi Jon,

Thanks for your inquiry. I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words for .NET 14.1.0. Please use Aspose.Words for .NET 14.1.0.

You are inserting HTML fragment into document. In this case, I suggest you please use the DocumentBuilder.InsertHtml as shown below.

var doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(@"your html");
doc.Save(MyDir + "Out.rtf", new RtfSaveOptions
{
    ExportCompactSize = true, SaveFormat = SaveFormat.Rtf
});

You can load whole HTML document into Aspose.Words DOM and save it to RTF as shown below. I have attached the input and output documents with this post for your kind reference.

var doc = new Document(MyDir + "in.html");
doc.Save(MyDir + "Out2.rtf", new RtfSaveOptions
{
    ExportCompactSize = true, SaveFormat = SaveFormat.Rtf
});