Click or drag to resize

RtfToHtmlHtmlSaveOptionsSingleFontFamily Property

Sets or gets a single font family for a whole text in the HTML document. Default value: Empty.

Namespace: SautinSoft
Assembly: SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 2024.6.6
Syntax
public string SingleFontFamily { get; set; }

Property Value

String
Remarks
By default each block of text will have the same font family as in the original document.
Example
Set single font family in 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)
        {
            SetSingleFontFamily();
        }
        /// <summary>
        /// How to convert to HTML document and set single font family a whole text.
        /// </summary>
        static void SetSingleFontFamily()
        {
            string inpFile = @"..\..\..\example.docx";
            string outFile = @"Result.html";

            RtfToHtml r = new RtfToHtml();

            RtfToHtml.HtmlFlowingSaveOptions opt = new RtfToHtml.HtmlFlowingSaveOptions()
            {
                Title = "Single font Courier",
                SingleFontFamily = "Courier"
            };

            try
            {
                r.Convert(inpFile, outFile, opt);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Conversion failed! {ex.Message}");
            }

            // Open the result.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
        }
    }
}
Set single font family in 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)
            SetSingleFontFamily()
        End Sub
        ''' <summary>
        ''' How to convert to HTML document and set single font family a whole text.
        ''' </summary>
        Private Shared Sub SetSingleFontFamily()
            Dim inpFile As String = "..\..\..\example.docx"
            Dim outFile As String = "Result.html"

            Dim r As New RtfToHtml()

            Dim opt As New RtfToHtml.HtmlFlowingSaveOptions() With {
                .Title = "Single font Courier",
                .SingleFontFamily = "Courier"
            }

            Try
                r.Convert(inpFile, outFile, opt)
            Catch ex As Exception
                Console.WriteLine($"Conversion failed! {ex.Message}")
            End Try

            ' Open the result.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also