Allows to set custom page numbers in produced Word/RTF document.

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

Syntax

      
 C#  Visual Basic 
public HtmlToRtf..::.CPageStyle..::.CPageNumbers PageNumbers { get; set; }
Public Property PageNumbers As HtmlToRtf..::.CPageStyle..::.CPageNumbers

Remarks

Using this property you may set custom page numbers as you wish. Use this property together with [!:SautinSoft.HtmlToRtf.CPageStyle.CPageNumbers.Appearence], AlignH and [!:.SautinSoft.HtmlToRtf.CPageStyle.CPageNumbers.AlignV].

These are special keywords to custom page numbers:

{page} - current page number
{numpages} - total pages
By default: Page numbers located at the bottom-right of page and represent digit(s), for example "1".

These are samples of using this property:

h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}";

h.PageStyle.PageNumbers.Format = "This is page number {page}";

h.PageStyle.PageNumbers.Format = "Seite {page} von {numpages}";



Examples

CopyHow to set custom page numbers in RTF document using C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Add page numbers
            // 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");

            // Set page margin top.
            h.PageStyle.PageMarginTop.Mm(20);


            // Add page numbers:
            // Let's set page numbers from 1st page
            h.PageStyle.PageNumbers.Appearance = SautinSoft.HtmlToRtf.ePageNumbers.PageNumFirst;
            // Lest's align page numbers by top-center
            h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Top;
            h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center;
            // Lest's set page numbers format as "Page 1 of 20".
            h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}";
            // Set page numbers font: Calibry, 19.
            h.PageStyle.PageNumbers.Font.Face = SautinSoft.HtmlToRtf.eFontFace.f_Calibri;
            h.PageStyle.PageNumbers.Font.Size = 19;

            // 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 custom page numbers in RTF document using VB.Net
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Add page numbers
        ' 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")

        ' Set page margin top.
        h.PageStyle.PageMarginTop.Mm(20)


        ' Add page numbers:
        ' Let's set page numbers from 1st page
        h.PageStyle.PageNumbers.Appearance = SautinSoft.HtmlToRtf.ePageNumbers.PageNumFirst
        ' Lest's align page numbers by top-center
        h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Top
        h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center
        ' Lest's set page numbers format as "Page 1 of 20".
        h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}"
        ' Set page numbers font: Calibry, 19.
        h.PageStyle.PageNumbers.Font.Face = SautinSoft.HtmlToRtf.eFontFace.f_Calibri
        h.PageStyle.PageNumbers.Font.Size = 19

        ' 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