public static string ToHtml(RtfSource source, RtfHtmlWriterSettings settings = null) { using (var stringWriter = new StringWriter()) { using (var writer = XmlWriter.Create(stringWriter, new XmlWriterSettings() { OmitXmlDeclaration = true })) { ToHtml(source, writer, settings); } return(stringWriter.ToString()); } }
public static void ToHtml(RtfSource source, XmlWriter writer, RtfHtmlWriterSettings settings = null) { settings = settings ?? new RtfHtmlWriterSettings(); var content = ParseRtf(source); // Try to extract encoded html from within the rtf (Outlook likes to do this) if (!BuildHtmlContent(content, writer)) { var intSettings = new RtfInterpreterSettings() { IgnoreDuplicatedFonts = true, IgnoreUnknownFonts = true }; var rtfDocument = RtfInterpreterTool.BuildDoc(content, intSettings); var htmlConvertSettings = new RtfHtmlConvertSettings(settings.ObjectVisitor); htmlConvertSettings.IsShowHiddenText = false; htmlConvertSettings.UseNonBreakingSpaces = false; htmlConvertSettings.ConvertScope = RtfHtmlConvertScope.All; var htmlConverter = new RtfHtmlConverter(rtfDocument, htmlConvertSettings); htmlConverter.Convert(writer); } }