This is a first sample how to convert RTF file to HTML file in C#, you will need only two lines of code:
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
r.ConvertFile(@"d:\test.rtf", @"d:\test.html");
This sample demonstrates how to convert RTF string to HTML string in C# (C Sharp), it usefull when you don't want to create physical files and work only with memory:
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
string rtf = @"{\rtf {\b bold text {\i bold + italic}} and plan text}";
string html = r.ConvertString(rtf);
The component has a lot of properties, for example when you want to export RTF into HTML with images you may save all images as physical files in a single folder or save images inside HTML document. C# sample how to force the dll store images in folder 'd:\my webs\images':
P.S. the folder 'd:\my webs' must exist, subfolder 'images' will be created by component.
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
r.ImageStyle.ImageFolder = @"d:\my webs";
r.ImageStyle.ImageSubFolder = "images";
r.ImageStyle.IncludeImageInHtml = false;
r.ConvertFile(@"d:\test.rtf", @"d:\test.html");
This is a C# sample how to force the dll store images inside HTML document. It's usefull when you want to make RTF converting in memory without creating any files on HDD. Images will be saved inside HTML using base64 algorithm:
SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
r.ImageStyle.IncludeImageInHtml = true;
string html = r.ConvertFileToString(@"d:\test.rtf");
|