Converts Text/RTF file to Text/HTML/XHTML file. Output file will be overwritten.
Namespace:
SautinSoftAssembly: SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 3.3.8.15
Syntax
| C# | Visual Basic |
Return Value
0 - converting succesfully1 - can't open input Text/RTF file, check the input path
2 - can't create output file, check the output path
3 - converting failed
Examples
using System; using System.IO; using System.Text; namespace SampleConvert { class sample { static void Main(string[] args) { SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml(); //this property is necessary only for registered version //r.Serial = "XXXXXXXXXXXXX"; //specify some options r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10; r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8; //specify image options r.ImageStyle.ImageFolder = @"c:\"; //this folder must exist r.ImageStyle.ImageSubFolder = "webs"; //this folder will be created by the component r.ImageStyle.ImageFileName = "picture"; //template name for images r.ImageStyle.IncludeImageInHtml = false;//false - save images on HDD, true - save images inside HTML string rtfFile = @"..\..\..\..\..\test.rtf"; string htmlFile = @"..\..\..\..\..\test.html"; int i = r.ConvertFile(rtfFile,htmlFile); if (i==0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(htmlFile); } else System.Console.WriteLine("Converting Error!"); } } }
Imports System Imports System.IO Imports System.Text Module sample Sub Main() Dim r As New SautinSoft.RtfToHtml() 'this property is necessary only for registered version 'r.Serial = "XXXXXXXXXXXXX"; 'specify some options r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10 r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8 'specify image options r.ImageStyle.ImageFolder = "c:\" 'this folder must exist r.ImageStyle.ImageSubFolder = "webs" 'this folder will be created by the component r.ImageStyle.ImageFileName = "picture" 'template name for images r.ImageStyle.IncludeImageInHtml = False 'False - save images on HDD, True - save images inside HTML Dim rtfFile As String = "..\..\..\..\test.rtf" Dim htmlFile As String = "..\..\..\..\test.html" Dim i As Integer = r.ConvertFile(rtfFile, htmlFile) If i = 0 Then System.Console.WriteLine("Converted successfully!") System.Diagnostics.Process.Start(htmlFile) Else System.Console.WriteLine("Converting Error!") End If End Sub End Module