Setup page header in any format: Html, Rtf or Text

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

Syntax

      
 C#  Visual Basic 
public HtmlToRtf..::.CHeaderFooter PageHeader { get; set; }
Public Property PageHeader As HtmlToRtf..::.CHeaderFooter

Remarks



Examples

CopyHow to set up header & footer in HTML format using C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Add page header and footer in HTML and RTF formats
            // 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, "sample doc.html");
            string rtfFile = Path.ChangeExtension(htmlFile, ".rtf");

            string headerAsHtml = File.ReadAllText(Path.Combine(htmlDir.FullName, "header.html"));
            string footerAsRtf = File.ReadAllText(Path.Combine(htmlDir.FullName, "footer.rtf"));

            // Add page header.
            h.PageStyle.PageHeader.Html(headerAsHtml);

            // Add extra space between header and page contents.
            h.PageStyle.PageHeader.MarginBottom.Mm(10);

            // Add page footer.
            h.PageStyle.PageFooter.Rtf(footerAsRtf);

            // Convert HTML to RTF
            int res = h.ConvertFile(htmlFile, rtfFile);

            if (res == 0)
            {
                Console.WriteLine("Converted successfully!");
                System.Diagnostics.Process.Start(rtfFile);
            }
            else
            {
                Console.WriteLine("Converting failed!");
                Console.ReadLine();
            }
        }
    }
}
CopyHow to set up header & footer in HTML format using VB.Net
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Add page header and footer in HTML and RTF formats
        ' 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, "sample doc.html")
        Dim rtfFile As String = Path.ChangeExtension(htmlFile, ".rtf")

        Dim headerAsHtml As String = File.ReadAllText(Path.Combine(htmlDir.FullName, "header.html"))
        Dim footerAsRtf As String = File.ReadAllText(Path.Combine(htmlDir.FullName, "footer.rtf"))

        ' Add page header.
        h.PageStyle.PageHeader.Html(headerAsHtml)

        ' Add extra space between header and page contents.
        h.PageStyle.PageHeader.MarginBottom.Mm(10)

        ' Add page footer.
        h.PageStyle.PageFooter.Rtf(footerAsRtf)

        ' Convert HTML to RTF
        Dim res As Integer = h.ConvertFile(htmlFile, rtfFile)

        If res = 0 Then
            Console.WriteLine("Converted successfully!")
            System.Diagnostics.Process.Start(rtfFile)
        Else
            Console.WriteLine("Converting failed!")
            Console.ReadLine()
        End If
    End Sub
End Module

See Also