Click or drag to resize

HtmlConvertOptionsBaseURL Property

It's target path of the HTML document base location.

Namespace: SautinSoft
Assembly: SautinSoft.HtmlToRtf (in SautinSoft.HtmlToRtf.dll) Version: 2023.12.6
Syntax
public string BaseURL { get; set; }

Property Value

String
Remarks
This is very important property when you are converting HTML document in memory. Specify a BaseURL that is it will convert all relative URLs on that page to absolute URLs.

For example, lets convert HTML string to RTF file.

If we've specified:

HtmlConvertOptions opt = new HtmlConvertOptions(); opt.BaseURL = @"d:\my webs";

When the component meets 'src="images/asterisk.jpg"' it will try to open it from: "d:\my webs\images\asterisk.jpg"

Example
Convert HTML url to RTF file using C#
using System;
using System.IO;
using SautinSoft;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Get your free 30-day key here:   
            // https://sautinsoft.com/start-for-free/

            // Convert HTML url to RTF file.
            // If you need more information about "HTML to RTF .Net" 
            // Email us at: support@sautinsoft.com.
            ConvertHtmlUrlToRtfFile();
        }

        public static void ConvertHtmlUrlToRtfFile()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            string inpFile = @"https://www.sautinsoft.net/samples/utf-8.html";
            string outFile = "Result.rtf";

            // Specify the 'BaseURL' property that component can find the full path to images, like a: <img src="..\pict.png" and
            // to external css, like a:  <link rel="stylesheet" href="/css/style.css">.
            HtmlConvertOptions opt = new HtmlConvertOptions();
            opt.BaseURL = @"https://www.sautinsoft.net/samples/utf-8.html";

            if (h.Convert(inpFile, outFile, opt))
            {
                // Open the result for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
            }
        }
    }
}
Convert HTML url to RTF file using VB.Net
Imports System
Imports System.IO
Imports SautinSoft

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            ' Get your free 30-day key here:   
            ' https://sautinsoft.com/start-for-free/

            ' Convert HTML url to RTF file.
            ' If you need more information about "HTML to RTF .Net" 
            ' Email us at: support@sautinsoft.com.
            ConvertHtmlUrlToRtfFile()
        End Sub

        Public Shared Sub ConvertHtmlUrlToRtfFile()
            Dim h As New SautinSoft.HtmlToRtf()

            Dim inpFile As String = "https://www.sautinsoft.net/samples/utf-8.html"
            Dim outFile As String = "Result.rtf"

            ' Specify the 'BaseURL' property that component can find the full path to images, like a: <img src="..\pict.png" and
            ' to external css, like a:  <link rel="stylesheet" href="/css/style.css">.
            Dim opt As New HtmlConvertOptions()
            opt.BaseURL = "https://www.sautinsoft.net/samples/utf-8.html"

            If h.Convert(inpFile, outFile, opt) Then
                ' Open the result for demonstration purposes.
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
            End If
        End Sub
    End Class
End Namespace
See Also