Skip to content

Commit a2afedd

Browse files
Merge pull request #513 from SyncfusionExamples/263711-RTFToHTML
263711-Convert RTF string to HTML string using DocIO
2 parents 4c7e289 + bca4f23 commit a2afedd

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36908.2 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-RTF-String-to-HTML-String", "Convert-RTF-String-to-HTML-String\Convert-RTF-String-to-HTML-String.csproj", "{850C464A-0682-420A-BA3B-65B41841A56C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{850C464A-0682-420A-BA3B-65B41841A56C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{850C464A-0682-420A-BA3B-65B41841A56C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{850C464A-0682-420A-BA3B-65B41841A56C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{850C464A-0682-420A-BA3B-65B41841A56C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {411E7CA8-6B93-4CB8-B1C6-60E844A154A0}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Convert_RTF_String_to_HTML_String</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.Text;
4+
5+
namespace Convert_RTF_String_To_HTML_String
6+
{
7+
public class Program
8+
{
9+
public static void Main(string[] args)
10+
{
11+
string rtfString = @"{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f0\fs60 Hello World!}";
12+
byte[] bytes = Encoding.ASCII.GetBytes(rtfString);
13+
MemoryStream streamRTF = new MemoryStream(bytes);
14+
WordDocument document = new WordDocument(streamRTF, FormatType.Rtf);
15+
MemoryStream ms = new MemoryStream();
16+
document.Save(ms, FormatType.Html);
17+
document.Close();
18+
ms.Position = 0;
19+
streamRTF.Close();
20+
string htmlString = Encoding.ASCII.GetString(ms.ToArray());
21+
Console.WriteLine(htmlString);
22+
ms.Close();
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)