Skip to content

Commit 727f105

Browse files
Merge pull request #526 from SyncfusionExamples/ES-929654-TxtToRTF
ES-929654-How to convert text file to RTF in C#
2 parents c7f55b7 + 09a1e86 commit 727f105

6 files changed

Lines changed: 130 additions & 0 deletions

File tree

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.36915.13 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-text-file-to-RTF", "Convert-text-file-to-RTF\Convert-text-file-to-RTF.csproj", "{08914445-D70E-8019-2963-69684D576876}"
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+
{08914445-D70E-8019-2963-69684D576876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{08914445-D70E-8019-2963-69684D576876}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{08914445-D70E-8019-2963-69684D576876}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{08914445-D70E-8019-2963-69684D576876}.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 = {1C46E81E-D023-4600-8B6B-DAC8CF38E500}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Convert_text_file_to_RTF</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Data\Template.txt">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
<None Update="Output\.gitkeep">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</None>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Northwind Database
2+
3+
The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases. Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data..
4+
5+
It contains the following detailed information:
6+
1. Suppliers/Vendors of Northwind � who supply to the company.
7+
2. Customers of Northwind � who buy from Northwind
8+
3. Employee details of Northwind traders � who work for Northwind
9+
4. The product information � the products that Northwind trades in
10+
5. The inventory details � the details of the inventory held by Northwind traders.
11+
6. The shippers � details of the shippers who ship the products from the traders to the end-customers
12+
7. PO transactions i.e Purchase Order transactions � details of the transactions taking place between vendors & the company.
13+
8. Sales Order transaction � details of the transactions taking place between the customers & the company.
14+
9. Inventory transactions � details of the transactions taking place in the inventory
15+
10. Invoices � details of the invoice raised against the order.

Text-file-conversion/Convert-text-file-to-RTF/.NET/Convert-text-file-to-RTF/Output/.gitkeep

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{\rtf1\ansi{\fonttbl{\af0\fcharset0 Times New Roman;}
2+
{\f1\fcharset0 Times New Roman;}
3+
}
4+
{\colortbl;}
5+
{\*\defchp\rtlch\fcs1\lang1033\af0\afs24\ltrch\fcs0\lang1033\f1\fs24\lang1033\langfenp1028\langfe1025}
6+
{\*\defpap\pard\plain\lang1033\widctlpar\ql\fi0\li0\ri0
7+
}
8+
{\stylesheet{\s1\lang1033\widctlpar\ql\fi0\li0\ri0
9+
\rtlch\fcs1\lang1033\af0\afs24\ltrch\fcs0\lang1033\f1\fs24\lang1033\langfenp1028\langfe1025\sqformat Normal;}{\cs2\additive\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\sqformat Default Paragraph Font;}}
10+
{\*\listoverridetable}
11+
\paperw11906\paperh16838\margl1000\margr400\margt400\margb400\spltpgpar\htmautsp\sectd\ltrsect\nofeaturethrottle1\formshade\splytwnine\headery720\footery720\vertalt\paperw11906\paperh16838\margl1000\margr400\margt400\margb400\gutter0\deftab720\pgncont\sectlinegrid0\cols0
12+
\fet0\pard\plain\lang1033\widctlpar\s1\ql\fi0\li0\ri0\rtlch\fcs1\lang1033\af0\afs24\ltrch\fcs0\lang1033\f1\fs24\lang1033\langfenp1028\langfe1025
13+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 Northwind Database}
14+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
15+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
16+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases. Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data..}
17+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
18+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
19+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 It contains the following detailed information:}
20+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
21+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 1. Suppliers/Vendors of Northwind \endash who supply to the company.}
22+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
23+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 2. Customers of Northwind \endash who buy from Northwind}
24+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
25+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 3. Employee details of Northwind traders \endash who work for Northwind}
26+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
27+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 4. The product information \endash the products that Northwind trades in}
28+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
29+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 5. The inventory details \endash the details of the inventory held by Northwind traders.}
30+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
31+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 6. The shippers \endash details of the shippers who ship the products from the traders to the end-customers}
32+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
33+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 7. PO transactions i.e Purchase Order transactions \endash details of the transactions taking place between vendors & the company.}
34+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
35+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 8. Sales Order transaction \endash details of the transactions taking place between the customers & the company.}
36+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
37+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 9. Inventory transactions \endash details of the transactions taking place in the inventory}
38+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
39+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1 10. Invoices \endash details of the invoice raised against the order.}
40+
{\rtlch\fcs1\lang1033\af0\ltrch\fcs0\lang1033\f1\par}
41+
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.IO;
4+
5+
namespace Convert_text_file_to_RTF
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Loads an existing Word document into DocIO instance.
12+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.txt"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
13+
{
14+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Txt))
15+
{
16+
//Creates file stream.
17+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.rtf"), FileMode.Create, FileAccess.ReadWrite))
18+
{
19+
//Saves the Word document to file stream.
20+
document.Save(outputFileStream, FormatType.Rtf);
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)