RtfToHtmlHtmlSaveOptionsEmbedImages Property |
Gets or sets a value indicating whether images are embedded directly within the
HTML file in form of Base64 encoding. Default value: true.
Namespace: SautinSoftAssembly: SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 2025.3.25
Syntaxpublic bool EmbedImages { get; set; }
Public Property EmbedImages As Boolean
Get
Set
Property Value
Boolean
ExampleHow to embed images in HTML using C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using SautinSoft;
namespace Example
{
class Program
{
static void Main(string[] args)
{
EmbedImages();
}
static void EmbedImages()
{
string inpFile = @"..\..\..\example.docx";
string htmlFileNonEmbeddedImg = Path.GetFullPath(@"NonEmbedded.html");
string imgDir = Path.GetDirectoryName(htmlFileNonEmbeddedImg);
string htmlFileEmbeddedImg = Path.GetFullPath(@"Embedded.html");
RtfToHtml r = new RtfToHtml();
RtfToHtml.HtmlFixedSaveOptions opt = new RtfToHtml.HtmlFixedSaveOptions()
{
ImagesDirectoryPath = Path.Combine(imgDir, "Result_images"),
ImagesDirectorySrcPath = "Result_images",
EmbedImages = false,
Title = "HTML with linked images."
};
try
{
r.Convert(inpFile, htmlFileNonEmbeddedImg, opt);
}
catch (Exception ex)
{
Console.WriteLine($"Conversion failed! {ex.Message}");
}
opt.EmbedImages = true;
opt.Title = "HTML with embedded images";
try
{
r.Convert(inpFile, htmlFileEmbeddedImg, opt);
}
catch (Exception ex)
{
Console.WriteLine($"Conversion failed! {ex.Message}");
}
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFileNonEmbeddedImg) { UseShellExecute = true });
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFileEmbeddedImg) { UseShellExecute = true });
}
}
}
How to embed images in HTML using VB.Net
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.IO
Imports SautinSoft
Namespace Example
Friend Class Program
Shared Sub Main(ByVal args() As String)
EmbedImages()
End Sub
Private Shared Sub EmbedImages()
Dim inpFile As String = "..\..\..\example.docx"
Dim htmlFileNonEmbeddedImg As String = Path.GetFullPath("NonEmbedded.html")
Dim imgDir As String = Path.GetDirectoryName(htmlFileNonEmbeddedImg)
Dim htmlFileEmbeddedImg As String = Path.GetFullPath("Embedded.html")
Dim r As New RtfToHtml()
Dim opt As new RtfToHtml.HtmlFixedSaveOptions() With {
.ImagesDirectoryPath = Path.Combine(imgDir, "Result_images"),
.ImagesDirectorySrcPath = "Result_images",
.EmbedImages = False,
.Title = "HTML with linked images."
}
Try
r.Convert(inpFile, htmlFileNonEmbeddedImg, opt)
Catch ex As Exception
Console.WriteLine($"Conversion failed! {ex.Message}")
End Try
opt.EmbedImages = True
opt.Title = "HTML with embedded images"
Try
r.Convert(inpFile, htmlFileEmbeddedImg, opt)
Catch ex As Exception
Console.WriteLine($"Conversion failed! {ex.Message}")
End Try
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(htmlFileNonEmbeddedImg) With {.UseShellExecute = True})
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(htmlFileEmbeddedImg) With {.UseShellExecute = True})
End Sub
End Class
End Namespace
See Also