This property is necessary when you convert RTF string to HTML string and want to see a relative path inside <img src="...."> tag
Namespace:
SautinSoftAssembly: SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 3.3.8.15
Syntax
Examples
using System; using System.IO; using System.Text; namespace SampleConvert { class Class1 { static void Main(string[] args) { //"Set image folder for properly exporting RTF to HTML string" SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml(); //specify some options r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10; r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8; //set image options r.ImageStyle.ImageFolder = Path.GetDirectoryName(Path.GetFullPath(@"..\..\..\..\..\test.rtf")); //this folder must exist r.DestFile = Path.GetFullPath(@"..\..\..\..\..\test.html"); //this folder must exist r.ImageStyle.ImageSubFolder = "images"; //this folder will be created by the component, check that folder has write permissions r.ImageStyle.ImageFileName = "picture"; //template name for images r.ImageStyle.IncludeImageInHtml = false;//false - save images on HDD, true - save images inside HTML r.ImageStyle.MakeAbsolutePathToImage = false; string rtfFile = @"..\..\..\..\..\test.rtf"; string htmlFile = @"..\..\..\..\..\test.html"; string rtfString = null; string htmlString = null; ReadFromFile(rtfFile,ref rtfString); htmlString = r.ConvertString(rtfString); if (htmlString != "") { System.Console.WriteLine("Converted successfully!"); WriteToFile(htmlFile,htmlString); System.Diagnostics.Process.Start(htmlFile); } else System.Console.WriteLine("Converting Error!"); } public static int ReadFromFile(string fileName,ref string fileStr) { try { FileInfo fi = new FileInfo(fileName); StreamReader strmRead = fi.OpenText(); fileStr = strmRead.ReadToEnd(); strmRead.Close(); return 0; } catch { //error open file System.Console.WriteLine("Error in open file"); return 1; } } public static int WriteToFile(string fileName, string fileStr) { try { StreamWriter sw = new StreamWriter(fileName, false); sw.Write(fileStr); sw.Close(); } catch { return 2; } return 0; } } }
Imports System Imports System.IO Imports System.Text Module sample Sub Main() 'Set image folder for properly exporting RTF to HTML string Dim r As New SautinSoft.RtfToHtml() 'specify some options r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10 r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8 'set image options r.ImageStyle.ImageFolder = Path.GetDirectoryName(Path.GetFullPath("..\..\..\..\test.rtf")) 'this folder must exist r.DestFile = Path.GetFullPath("..\..\..\..\test.html") 'this folder must exist r.ImageStyle.ImageSubFolder = "images" 'this folder will be created by the component, check that folder has write permissions r.ImageStyle.ImageFileName = "picture" 'template name for images r.ImageStyle.IncludeImageInHtml = False 'false - save images on HDD, true - save images inside HTML r.ImageStyle.MakeAbsolutePathToImage = False Dim rtfFile As String = "..\..\..\..\test.rtf" Dim htmlFile As String = "..\..\..\..\test.html" Dim rtfString As String = Nothing Dim htmlString As String = Nothing ReadFromFile(rtfFile, rtfString) htmlString = r.ConvertString(rtfString) If htmlString <> "" Then System.Console.WriteLine("Converted successfully!") WriteToFile(htmlFile, htmlString) System.Diagnostics.Process.Start(htmlFile) Else System.Console.WriteLine("Converting Error!") End If End Sub Public Function ReadFromFile(ByVal fileName As String, ByRef fileStr As String) As Integer Try Dim fi As New FileInfo(fileName) Dim strmRead As StreamReader = fi.OpenText() fileStr = strmRead.ReadToEnd() strmRead.Close() Return 0 Catch 'error open file System.Console.WriteLine("Can't open file!") Return 1 End Try End Function Public Function WriteToFile(ByVal fileName As String, ByVal fileStr As String) As Integer Try Dim sw As New StreamWriter(fileName, False) sw.Write(fileStr) sw.Close() Catch Return 2 End Try Return 0 End Function End Module