Click or drag to resize

RtfToHtmlHtmlSaveOptionsProduceOnlyHtmlBody Property

Gets or sets a value to produce a complete HTML document or only between between <body>...</body> tags. Default value: false.

Namespace: SautinSoft
Assembly: SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 2025.4.24
Syntax
public bool ProduceOnlyHtmlBody { get; set; }

Property Value

Boolean
Remarks
In case of 'True' you will get only HTML between <body>...</body> tags.
This property will be useful to merge multiply HTML documents into a single.
Example
Produce only HTML body 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)
        {
            ProduceOnlyHtmlBody();
        }
        /// <summary>
        /// How to produce HTML document only between &lt;body&gt;...&lt;/body&gt; tags.
        /// </summary>
        static void ProduceOnlyHtmlBody()
        {
            // Get your free key here:   
            // https://sautinsoft.com/start-for-free/

            // If you need more information about "RTF to HTML .Net" 
            // Email us at: support@sautinsoft.com.

            string inpFile = @"..\..\..\example.docx";
            string outFile = @"Result.html";

            RtfToHtml r = new RtfToHtml();

            // Set properties to produce HTML document only
            // between &lt;body&gt;...&lt;/body&gt; tags
            RtfToHtml.HtmlFlowingSaveOptions opt = new RtfToHtml.HtmlFlowingSaveOptions()
            {
                ProduceOnlyHtmlBody = true
            };

            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 });
        }
    }
}
Produce only HTML body 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)
            ProduceOnlyHtmlBody()
        End Sub
        ''' <summary>
        ''' How to produce HTML document only between &lt;body&gt;...&lt;/body&gt; tags.
        ''' </summary>
        Private Shared Sub ProduceOnlyHtmlBody()
                    ' Get your free key here:   
            ' https://sautinsoft.com/start-for-free/

            ' If you need more information about "RTF to HTML .Net" 
            ' Email us at: support@sautinsoft.com.
            Dim inpFile As String = "..\..\..\example.docx"
            Dim outFile As String = "Result.html"

            Dim r As New RtfToHtml()

            ' Set properties to produce HTML document only
            ' between &lt;body&gt;...&lt;/body&gt; tags
            Dim opt As New RtfToHtml.HtmlFlowingSaveOptions() With {
                .ProduceOnlyHtmlBody = True
            }

            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