Click or drag to resize

HeaderFooter Constructor (DocumentCore, HeaderFooterType, Block)

Initializes a new instance of the HeaderFooter class.

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 5.3.6.22
Syntax
public HeaderFooter(
	DocumentCore document,
	HeaderFooterType headerFooterType,
	params Block[] items
)

Parameters

document
Type: SautinSoft.DocumentDocumentCore
The owner document.
headerFooterType
Type: SautinSoft.DocumentHeaderFooterType
Type of the header / footer.
items
Type: SautinSoft.DocumentBlock
The header / footer content.
Examples
How to add a header and footer into PDF document using C#
using System.IO;
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            AddHeaderFooter();
        }

        /// <summary>
        /// How to add a header and footer into PDF document.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/add-header-and-footer-in-pdf-net-csharp-vb.php
        /// </remarks>
        static void AddHeaderFooter()
        {
            string inpFile = @"..\..\shrek.pdf";
            string outFile = "Shrek with header and footer.pdf";
            DocumentCore dc = DocumentCore.Load(inpFile);

            // Create new header with formatted text.
            HeaderFooter header = new HeaderFooter(dc, HeaderFooterType.HeaderDefault);
            header.Content.Start.Insert("Shrek and Donkey", new CharacterFormat() { Size = 14.0, FontColor = Color.Brown });
            foreach (Section s in dc.Sections)
            {
                s.HeadersFooters.Add(header.Clone(true));
            }

            // Create new footer with formatted text.
            HeaderFooter footer = new HeaderFooter(dc, HeaderFooterType.FooterDefault);
            footer.Content.Start.Insert("Fiona.", new CharacterFormat() { Size = 14.0, FontColor = Color.Blue });
            foreach (Section s in dc.Sections)
            {
                s.HeadersFooters.Add(footer.Clone(true));
            }

            dc.Save(outFile);

            // Open the PDF documents for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(inpFile) { UseShellExecute = true });
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
        }
    }
}
How to add a header and footer into PDF document using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        AddHeaderFooter()
    End Sub

    ''' <summary>
    ''' How to add a header and footer into PDF document.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/add-header-and-footer-in-pdf-net-csharp-vb.php
    ''' </remarks>
    Sub AddHeaderFooter()
        Dim inpFile As String = "..\shrek.pdf"
        Dim outFile As String = "Shrek with header and footer.pdf"
        Dim dc As DocumentCore = DocumentCore.Load(inpFile)

        ' Create new header with formatted text.
        Dim header As New HeaderFooter(dc, HeaderFooterType.HeaderDefault)
        header.Content.Start.Insert("Shrek and Donkey", New CharacterFormat() With {
                .Size = 14.0,
                .FontColor = Color.Brown
            })
        For Each s As Section In dc.Sections
            s.HeadersFooters.Add(header.Clone(True))
        Next s

        ' Create new footer with formatted text.
        Dim footer As New HeaderFooter(dc, HeaderFooterType.FooterDefault)
        footer.Content.Start.Insert("Fiona.", New CharacterFormat() With {
                .Size = 14.0,
                .FontColor = Color.Blue
            })
        For Each s As Section In dc.Sections
            s.HeadersFooters.Add(footer.Clone(True))
        Next s

        dc.Save(outFile)

        ' Open the PDF documents for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(inpFile) With {.UseShellExecute = True})
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
    End Sub
End Module
See Also