Конвертирование DOCX and RTF to HTML in .NET Core
на C# и .NET
Полный код
using System;
namespace Sample
{
internal class Sample
{
private static void Main(string[] args)
{
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
string inpFile1 = @"..\..\..\example.rtf";
string inpFile2 = @"..\..\..\example.docx";
string outFile1 = @"Result RTF.html";
string outFile2 = @"Result DOCX.html";
SautinSoft.RtfToHtml.HtmlFixedSaveOptions opt1 = new SautinSoft.RtfToHtml.HtmlFixedSaveOptions()
{
Title = "Produced from RTF.",
EmbedImages = true,
};
SautinSoft.RtfToHtml.HtmlFixedSaveOptions opt2 = new SautinSoft.RtfToHtml.HtmlFixedSaveOptions()
{
Title = "Produced from DOCX.",
EmbedImages = true,
};
try
{
r.Convert(inpFile1, outFile1, opt1);
r.Convert(inpFile2, outFile2, opt2);
// Open the results for demonstration purposes.
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile1)
{ UseShellExecute = true });
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile2)
{ UseShellExecute = true });
}
catch (Exception e)
{
Console.WriteLine($"Error: {e.Message}");
Console.WriteLine("Press any key ...");
Console.ReadKey();
}
}
}
}
Imports System
Namespace Sample
Friend Class Sample
Public Shared Sub Main(ByVal args() As String)
Dim r As New SautinSoft.RtfToHtml()
Dim inpFile1 As String = "..\..\..\example.rtf"
Dim inpFile2 As String = "..\..\..\example.docx"
Dim outFile1 As String = "Result RTF.html"
Dim outFile2 As String = "Result DOCX.html"
Dim opt1 As New SautinSoft.RtfToHtml.HtmlFixedSaveOptions() With {
.Title = "Produced from RTF.",
.EmbedImages = True
}
Dim opt2 As New SautinSoft.RtfToHtml.HtmlFixedSaveOptions() With {
.Title = "Produced from DOCX.",
.EmbedImages = True
}
Try
r.Convert(inpFile1, outFile1, opt1)
r.Convert(inpFile2, outFile2, opt2)
' Open the results for demonstration purposes.
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile1) With {.UseShellExecute = True})
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile2) With {.UseShellExecute = True})
Catch e As Exception
Console.WriteLine($"Error: {e.Message}")
Console.WriteLine("Press any key ...")
Console.ReadKey()
End Try
End Sub
End Class
End Namespace
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: