Class which allows to operate with images in memory during HTML to RTF and vice versa

Namespace:  SautinSoft
Assembly:  SautinSoft.HtmlToRtf (in SautinSoft.HtmlToRtf.dll) Version: 5.8.2.8

Syntax

      
 C#  Visual Basic 
public class SautinImage : IDisposable
Public Class SautinImage _
	Implements IDisposable

Members

         
 All Members  Properties   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
Cid
Image Cid
Dispose()()()
Release Img from memory.
Img
Object of the Image standard class

Remarks

Examples

CopyConvert HTML to RTF and place all images in List using C#
using System;
using System.IO;
using System.Collections.Generic;
using SautinSoft;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Convert HTML to RTF and place all images in List
            // If you need more information about "HTML to RTF .Net" email us at:
            // support[at]sautinsoft.com        
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();
            // After purchasing the license, please insert your serial number here to activate the component
            //h.Serial = "XXXXXXXXXXXXXXX";

            DirectoryInfo htmlDir = new DirectoryInfo(@"..\..\..\..\..\..\Testing HTMLs");
            string htmlFile = Path.Combine(htmlDir.FullName, "pic.html");
            string rtfFile = Path.ChangeExtension(htmlFile, ".rtf");


            // List with images extracted from HTML document.
            List<HtmlToRtf.SautinImage> imgList = new List<HtmlToRtf.SautinImage>();

            string htmlString = File.ReadAllText(htmlFile);

            // Set BaseUrl to transform relative paths into absolute.
            h.BaseURL = htmlDir.FullName;

            // Convert HTML to RTF in memory and extract images to imgList.
            string rtfString = h.ConvertString(htmlString, imgList);

            if (rtfString!=null)
            {
                File.WriteAllText(rtfFile, rtfString);
                Console.WriteLine("Converted successfully!");
                System.Diagnostics.Process.Start(rtfFile);
            }
            else
            {
                Console.WriteLine("Converting failed!");
                Console.ReadLine();
            }
        }
    }
}
CopyConvert HTML to RTF and place all images in List using VB.Net
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Text

Module Module1
    Sub Main()
        ' Convert HTML to RTF and place all images in List
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' support[at]sautinsoft.com        
        Dim h As New SautinSoft.HtmlToRtf()
        ' After purchasing the license, please insert your serial number here to activate the component
        'h.Serial = "XXXXXXXXXXXXXXX";


        Dim htmlDir As New DirectoryInfo("..\..\..\..\..\Testing HTMLs")
        Dim htmlFile As String = Path.Combine(htmlDir.FullName, "pic.html")
        Dim rtfFile As String = Path.ChangeExtension(htmlFile, ".rtf")


        ' List with images extracted from HTML document.
        Dim imgList As New Generic.List(Of SautinSoft.HtmlToRtf.SautinImage)()

        Dim htmlString As String = File.ReadAllText(htmlFile)

        ' Set BaseUrl to transform relative paths into absolute.
        h.BaseURL = htmlDir.FullName

        ' Convert HTML to RTF in memory and extract images to imgList.
        Dim rtfString As String = h.ConvertString(htmlString, imgList)

        If rtfString IsNot Nothing Then
            File.WriteAllText(rtfFile, rtfString)
            Console.WriteLine("Converted successfully!")
            System.Diagnostics.Process.Start(rtfFile)
        Else
            Console.WriteLine("Converting failed!")
            Console.ReadLine()
        End If
    End Sub
End Module

Inheritance Hierarchy

System..::.Object
  SautinSoft..::.HtmlToRtf..::.SautinImage

See Also