Gets or sets a path to a directory to store images after converting. Notice also to the property "ImageSubFolder".

Namespace:  SautinSoft
Assembly:  SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 6.2.2.1

Syntax

      
 C#  Visual Basic 
public string ImageFolder { get; set; }
Public Property ImageFolder As String

Remarks

Notice: The folder must exist. The component can't and will not create this folder.
The path must be an absolute and starts from a drive letter: "C:\.." or "D:\" etc.

Default value: The parent directory of the input HTML document when you are working with files or "String.Empty" when you are working using memory.

Examples

CopySet image folder for properly exporting RTF to HTML string using C#
using System;
using System.IO;
using System.Text;

namespace SampleConvert
{
    class sample
    {
        static void Main(string[] args)
        {
            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
            string AppPath=System.Environment.CurrentDirectory;

            //specify some options
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10;
            r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            //specify image options
            r.ImageStyle.ImageFolder = AppPath;            //this folder must exist
            r.ImageStyle.ImageSubFolder = "test.files";    //this folder will be created by the component
            r.ImageStyle.ImageFileName = "img";            //template name for images
            r.ImageStyle.IncludeImageInHtml = false;    //false - save images on HDD, true - save images inside HTML

            r.ImageStyle.ImageNumStart = 101;            //considering that we have 100 images in that folder already

            string rtfFile = Path.GetFullPath(@"..\..\..\..\..\test.rtf");

            //1. Converting test file with absolute image paths
            r.ImageStyle.MakeAbsolutePathToImage = true;

            string htmlFile = Path.Combine(AppPath,"test-absolute.html"); //the result will be located in the same folder as binary

            int i = r.ConvertFile(rtfFile,htmlFile);
            if (i==0)
            {
                System.Console.WriteLine("Test file 1 converted successfully!");
                System.Diagnostics.Process.Start(htmlFile);
            }
            else
                System.Console.WriteLine("Test file 1 conversion failed!");

            //2. Converting test file with images embedded in HTML
            htmlFile = Path.Combine(AppPath,"test-embedded.html"); 
            r.ImageStyle.IncludeImageInHtml = true;

            i = r.ConvertFile(rtfFile,htmlFile);
            if (i==0)
            {
                System.Console.WriteLine("Test file 2 converted successfully!");
                System.Diagnostics.Process.Start(htmlFile);
            }
            else
                System.Console.WriteLine("Test file 2 conversion failed!");

            //3. Converting test file without images
            htmlFile = Path.Combine(AppPath,"test-no-images.html"); 
            r.ImageStyle.PreserveImages = false;

            i = r.ConvertFile(rtfFile,htmlFile);
            if (i==0)
            {
                System.Console.WriteLine("Test file 3 converted successfully!");
                System.Diagnostics.Process.Start(htmlFile);
            }
            else
                System.Console.WriteLine("Test file 3 conversion failed!");
        }
    }
}
CopySet image folder for properly exporting RTF to HTML string using VB.Net
Imports System.IO
Imports System.Text

Namespace SampleConvert
    Friend Class sample
        Shared Sub Main(ByVal args() As String)
            Dim r As New SautinSoft.RtfToHtml()
            Dim AppPath As String = System.Environment.CurrentDirectory

            'specify some options
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10
            r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8

            'specify image options
            r.ImageStyle.ImageFolder = AppPath 'this folder must exist
            r.ImageStyle.ImageSubFolder = "test.files" 'this folder will be created by the component
            r.ImageStyle.ImageFileName = "img" 'template name for images
            r.ImageStyle.IncludeImageInHtml = False 'false - save images on HDD, true - save images inside HTML


            r.ImageStyle.ImageNumStart = 101 'considering that we have 100 images in that folder already


            Dim rtfFile As String = Path.GetFullPath("..\..\..\..\..\test.rtf")

            '1. Converting test file with absolute image paths
            r.ImageStyle.MakeAbsolutePathToImage = True

            Dim htmlFile As String = Path.Combine(AppPath, "test-absolute.html") 'the result will be located in the same folder as binary


            Dim i As Integer = r.ConvertFile(rtfFile, htmlFile)
            If i = 0 Then
                System.Console.WriteLine("Test file 1 converted successfully!")
                System.Diagnostics.Process.Start(htmlFile)
            Else
                System.Console.WriteLine("Test file 1 conversion failed!")
            End If

            '2. Converting test file with images embedded in HTML
            htmlFile = Path.Combine(AppPath, "test-embedded.html")
            r.ImageStyle.IncludeImageInHtml = True

            i = r.ConvertFile(rtfFile, htmlFile)
            If i = 0 Then
                System.Console.WriteLine("Test file 2 converted successfully!")
                System.Diagnostics.Process.Start(htmlFile)
            Else
                System.Console.WriteLine("Test file 2 conversion failed!")
            End If

            '3. Converting test file without images
            htmlFile = Path.Combine(AppPath, "test-no-images.html")
            r.ImageStyle.PreserveImages = False

            i = r.ConvertFile(rtfFile, htmlFile)
            If i = 0 Then
                System.Console.WriteLine("Test file 3 converted successfully!")
                System.Diagnostics.Process.Start(htmlFile)
            Else
                System.Console.WriteLine("Test file 3 conversion failed!")
            End If
        End Sub
    End Class
End Namespace

See Also