Set header/footer from any RTF string

Namespace:  SautinSoft
Assembly:  PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 6.7.12.19

Syntax

      
 C#  Visual Basic 
public void Rtf(
	string rtf
)
Public Sub Rtf ( _
	rtf As String _
)

Parameters

rtf
String
String in RTF format

Remarks

This method is very usefull when you want to insert header/footer from RTF document without reading files.

Examples

CopyHow to set custom page header & footer for HTML to PDF in C#
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            //How to add page header and footer
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
            //After purchasing the license, please insert your serial number here to activate the component
            //p.Serial = "XXXXXXXXXXX";

            //Let's add page header in HTML format
            string headerInHtml = "<table width=\"100%\" border=\"1\"><tr><td width=\"50%\" align=\"center\"><img src=\"http://www.google.com/intl/en_com/images/srpr/logo3w.png\" /></td><td>You are welcome!</td></tr></table>";
            p.PageSettings.Header.Html(headerInHtml);

            string footerInRtf = @"{\i Italic Header}";
            p.PageSettings.Footer.Rtf(footerInRtf);

            if (p != null)
            {
                string inputFile = @"..\..\..\..\..\test.htm";
                string outputFile = @"..\..\..\..\..\test.pdf";

                int result = p.HtmlToPdfConvertFile(inputFile, outputFile);

                if (result == 0)
                {
                    System.Console.WriteLine("Converted successfully!");
                    System.Diagnostics.Process.Start(outputFile);
                }
                else
                {
                    System.Console.WriteLine("Converting Error!");
                }
            }
        }
    }
}
CopyHow to set custom page header & footer for HTML to PDF in VB.Net
Imports System
Imports System.IO
Imports System.Text

Module sample

    Sub Main()
        'How to add page header and footer
        Dim p As New SautinSoft.PdfMetamorphosis()

        'After purchasing the license, please insert your serial number here to activate the component
        'p.Serial = "XXXXXXXXXXX";


        'Let's add page header in HTML format
        Dim headerInHtml As String = "<table width=""100%"" border=""1""><tr><td width=""50%"" align=""center""><img src=""http://www.google.com/intl/en_com/images/srpr/logo3w.png"" /></td><td>You are welcome!</td></tr></table>"
        p.PageSettings.Header.Html(headerInHtml)

        Dim footerInRtf As String = "{\i Italic Header}"
        p.PageSettings.Footer.Rtf(footerInRtf)

        If p IsNot Nothing Then
            Dim inputFile As String = "..\..\..\..\..\test.htm"
            Dim outputFile As String = "..\..\..\..\..\test.pdf"

            Dim result As Integer = p.HtmlToPdfConvertFile(inputFile, outputFile)

            If result = 0 Then
                System.Console.WriteLine("Converted successfully!")
                System.Diagnostics.Process.Start(outputFile)
            Else
                System.Console.WriteLine("Converting Error!")
            End If
        End If
    End Sub
End Module

See Also