Set header/footer from any HTML string.

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

Syntax

      
 C#  Visual Basic 
public void Html(
	string html
)
Public Sub Html ( _
	html As String _
)

Parameters

html
String
String in HTML format

Remarks

We don't recommend to use it for complex HTML documents as header or footer. The best is using simple HTML table with text and images as header/footer.

Examples

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

namespace Sample
{
    class Test
    {

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

            if (p != null)
            {                
                string inputFile = @"..\..\..\..\..\test with footer.rtf";
                string originalPdf = @"..\..\..\..\..\Original.pdf";
                string customPdf = @"..\..\..\..\..\Custom.pdf";

                // Let's convert RTF which has an own page footer to PDF
                if (p.RtfToPdfConvertFile(inputFile, originalPdf)==0)
                {
                    System.Diagnostics.Process.Start(originalPdf);
                }
                // Let's change the footer to custom
                string footerInHtml = "<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>This is new custom footer!</td></tr></table>";
                p.PageSettings.Footer.Html(footerInHtml);

                // Let's convert RTF to PDF and change the footer to the custom
                if (p.RtfToPdfConvertFile(inputFile, customPdf) == 0)
                {
                    System.Diagnostics.Process.Start(customPdf);
                }
            }
        }
    }
}
CopyHow to set custom header & footer in HTML format using VB.Net
Imports System
Imports System.IO
Imports System.Text

Module sample

    Sub Main()
        'How to change the page footer to the custom footer
        Dim p As New SautinSoft.PdfMetamorphosis()
        'After purchasing the license, please insert your serial number here to activate the component
        'p.Serial = "XXXXXXXXXXX";


        If p IsNot Nothing Then
            Dim inputFile As String = "..\..\..\..\..\test with footer.rtf"
            Dim originalPdf As String = "..\..\..\..\..\Original.pdf"
            Dim customPdf As String = "..\..\..\..\..\Custom.pdf"

            'Let's convert RTF which has a page footer to PDF
            If p.RtfToPdfConvertFile(inputFile, originalPdf) = 0 Then
                System.Diagnostics.Process.Start(originalPdf)
            End If
            'Let's change footer to the custom
            Dim footerInHtml 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>This is new custom footer!</td></tr></table>"
            p.PageSettings.Footer.Html(footerInHtml)
            'Let's convert RTF which has a page footer to PDF
            If p.RtfToPdfConvertFile(inputFile, customPdf) = 0 Then
                System.Diagnostics.Process.Start(customPdf)
            End If
        End If
    End Sub
End Module

See Also