WinForms - HTML to RichTextBox and Vice Versa
на C# и .NET
Code
private void btnConvert_Click(object sender, EventArgs e)
{
SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();
// After purchasing the license, please insert your serial number here to activate the component.
// h.Serial = "XXXXXXXXX";
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
// 1. Convert RTF to HTML
r.OpenRtf(richTextBox1.Rtf);
r.ImageStyle.IncludeImageInHtml = true;
string html = String.Empty;
r.ToHtml(out html);
if (chkOpen.Checked)
{
File.WriteAllText("Result.html", html);
System.Diagnostics.Process.Start("Result.html");
}
// 2. Convert HTML to RTF
if (h.OpenHtml(html))
richTextBox1.Rtf = h.ToRtf();
}
Private Sub btnConvert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConvert.Click
Dim h As New SautinSoft.HtmlToRtf()
h.RtfCompatibility = SautinSoft.HtmlToRtf.eRtfCompatibility.OldRtfReaders
Dim r As New SautinSoft.RtfToHtml()
' 1. Convert RTF to HTML
r.OpenRtf(richTextBox1.Rtf)
r.ImageStyle.IncludeImageInHtml = True
Dim html As String = Nothing
r.ToHtml(html, Nothing)
If chkOpen.Checked Then
File.WriteAllText("Result.html", html)
System.Diagnostics.Process.Start("Result.html")
End If
' 2. Convert HTML to RTF
richTextBox1.Rtf = h.ConvertString(html)
End Sub
End Class
End Namespace
If you are looking also for a .NET solution to Create or Modify HTML documents, see our Document .Net.
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: