Skip to main content

PageNumberingLabel

Version: 8.0

cete.dynamicpdf.pageelements.pagenumberinglabel

PageNumberingLabel​

Represents a page numbering label page element.

public class PageNumberingLabel : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class PageNumberingLabel
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable

Inheritance: Object → PageElement → TaggablePageElement → RotatingPageElement → PageNumberingLabel

Implements: IArea, ICoordinate, ISerializable

Licensing​

This class is a DynamicPDF Generator Community Edition feature.

Examples​

The following example shows how to use page numbering in a document.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements

Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a document template and add it to the document
Dim documentTemplate As Template = New Template()
MyDocument.Template = documentTemplate

' Place a page numbering label in the document template
documentTemplate.Elements.Add( New PageNumberingLabel( _ "%%PR%%%%SP%% of %%ST%%", 0, 680, 512, 12, Font.Helvetica, _ 12, TextAlign.Center ) )

' Begin the first section
MyDocument.Sections.Begin( NumberingStyle.RomanLowerCase )

' Add three pages
MyDocument.Pages.Add( new Page() ) 'Page 1
MyDocument.Pages.Add( new Page() ) 'Page 2
MyDocument.Pages.Add( new Page() ) 'Page 3

' Begin the second section
MyDocument.Sections.Begin( NumberingStyle.Numeric )

' Add four pages
MyDocument.Pages.Add( new Page() ) 'Page 4
MyDocument.Pages.Add( new Page() ) 'page 5
MyDocument.Pages.Add( new Page() ) 'page 6
MyDocument.Pages.Add( new Page() ) 'page 7

' Begin the third section specifying a section prefix
MyDocument.Sections.Begin( NumberingStyle.RomanLowerCase, _ "Appendix A - " )

' Add two pages
MyDocument.Pages.Add( new Page() ) 'page 8
MyDocument.Pages.Add( new Page() ) 'page 9

' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

class MyClass
{
static void Main()
{
// Create a PDF Document
Document document = new Document();

// Create a document template and add it to the document
Template documentTemplate = new Template();
document.Template = documentTemplate;

// Place a page numbering label in the document template
documentTemplate.Elements.Add( new PageNumberingLabel( "%%PR%%%%SP%% of %%ST%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center ) );

// Begin the first section
document.Sections.Begin( NumberingStyle.RomanLowerCase );

// Add three pages
document.Pages.Add( new Page() ); //Page 1
document.Pages.Add( new Page() ); //Page 2
document.Pages.Add( new Page() ); //Page 3

// Begin the second section
document.Sections.Begin( NumberingStyle.Numeric );

// Add four pages
document.Pages.Add( new Page() ); //Page 4
document.Pages.Add( new Page() ); //page 5
document.Pages.Add( new Page() ); //page 6
document.Pages.Add( new Page() ); //page 7

// Begin the third section specifying a section prefix
document.Sections.Begin( NumberingStyle.RomanLowerCase, "Appendix A - " );

// Add two pages
document.Pages.Add( new Page() ); //page 8
document.Pages.Add( new Page() ); //page 9

// Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
}
}

Remarks​

This class can be used to add page and section numbering to a PDF document. A document can be broken up into sections using the Sections property of the Document class. The following tokens can be used within the text of a PageNumberingLabel. They will be replaced with the appropriate value when the PDF is output.

Token Description- CP Current page. The default numbering style is numeric. The current page can be offset using the is offset by the PageOffset property.

  • TP Total pages. The default numbering style is numeric. The total pages can be offset using the is offset by the PageTotalOffset property.
  • SP Section page. The default numbering style is the numbering style used by the section. The total pages can be offset using the is offset by the PageTotalOffset property.
  • ST Section Total. The default numbering style is the numbering style used by the section. The total pages can be offset using the is offset by the PageTotalOffset property.
  • PR Prefix. The sections prefix.

All tokens except the /%/%PR/%/% token can also contain a numbering style specifier. The numbering style specifier is placed in parenthesis after the token. If no numbering style specifier is given, then the current sections numbering specifier is used. If there are no document sections or the current section does not have a numbering specifier, numeric numbering is used. Numbering Style Description- 1 Numeric. Arabic numbers are used: 1, 2, 3, etc. Example: "/%/%CP(1)/%/%"

  • i Lower Case Roman Numerals. Lower case roman numerals are used: i, ii, iii, etc. Example: "/%/%CP(i)/%/%".
  • I Upper Case Roman Numerals. Upper case roman numerals are used: I, II, III, etc. Example: "/%/%CP(I)/%/%".
  • a Lower Latin Letters. Lower case Latin letters are used: a, b, c, etc. After z, aa is used followed by bb, cc, etc. Example: "/%/%CP(a)/%/%".
  • A Upper Latin Letters. Upper case Latin letters are used: A, B, C, etc. After Z, AA is used followed by BB, CC, etc. Example: "/%/%CP(A)/%/%".
  • b Lower Latin Letters. Lower case Latin letters are used: a, b, c, etc. After z, aa is used followed by ab, ac, etc. Example: "/%/%CP(b)/%/%".
  • B Lower Latin Letters. Lower case Latin letters are used: A, B, C, etc. After Z, AA is used followed by AB, AC, etc. Example: "/%/%CP(B)/%/%".

There should be no spaces within a token, only the token and optional numbering style specifier. This token is invalid /%/%CP ( i )/%/% because of the extra spaces.

Here are some examples of valid tokens: /%/%SP/%/% /%/%SP(I)/%/% /%/%PR/%/% /%/%ST(B)/%/%

Constructors​

PageNumberingLabel(String, Single, Single, Single, Single)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

PageNumberingLabel(String, Single, Single, Single, Single, Font)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height, Font font)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

Font for the text of the label.

PageNumberingLabel(String, Single, Single, Single, Single, Font, Single)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height, Font font, float fontSize)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

Font for the text of the label.

Font size of the text of the label.

PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, Color)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height, Font font, float fontSize, Color textColor)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, textColor As Color)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

Font for the text of the label.

Font size of the text of the label.

Color of the text of the label.

PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, TextAlign)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height, Font font, float fontSize, TextAlign align)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, align As TextAlign)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

Font for the text of the label.

Font size of the text of the label.

Alignment of the text of the label.

PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, TextAlign, Color)​

Initializes a new instance of the PageNumberingLabel class.

public PageNumberingLabel(string text, float x, float y, float width, float height, Font font, float fontSize, TextAlign align, Color textColor)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, align As TextAlign, textColor As Color)

Parameters​

Text to display in the label.

X coordinate of the label.

Y coordinate of the label.

Width of the label.

Height of the label.

Font for the text of the label.

Font size of the text of the label.

Alignment of the text of the label.

Color of the text of the label.

Properties​

Align​

Gets or sets the Align enumeration that specifies the text alignment of the label.

public TextAlign Align { get; set; }
Public Property Align As TextAlign

Property Value​

TextAlign

Angle​

Gets or sets the heights of the angle element. (Inherited from RotatingPageElement)

public float Angle { get; set; }
Public Property Angle As Single

Property Value​

Single

Font​

Gets or sets the Font object to use for the text of the label.

public Font Font { get; set; }
Public Property Font As Font

Property Value​

Font

FontSize​

Gets or sets the font size for the text of the label.

public float FontSize { get; set; }
Public Property FontSize As Single

Property Value​

Single

Height​

Gets or sets the heights of the page element. (Inherited from RotatingPageElement)

public float Height { get; set; }
Public Property Height As Single

Property Value​

Single

ID​

Gets or sets the ID of the page element. (Inherited from PageElement)

public string ID { get; set; }
Public Property ID As String

Property Value​

String

PageOffset​

Gets or sets the page offset for page numbering.

public int PageOffset { get; set; }
Public Property PageOffset As Int32

Property Value​

Int32

PageTotalOffset​

Gets or sets the page total offset for page numbering.

public int PageTotalOffset { get; set; }
Public Property PageTotalOffset As Int32

Property Value​

Int32

Tag​

Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement)

public Tag Tag { get; set; }
Public Property Tag As Tag

Property Value​

Tag

Licensing​

This property is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

TagOrder​

Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement)

public int TagOrder { get; set; }
Public Property TagOrder As Int32

Property Value​

Int32

Text​

Gets or sets the text of the label.

public string Text { get; set; }
Public Property Text As String

Property Value​

String

TextColor​

Gets or sets the Color object to use for the text of the label.

public Color TextColor { get; set; }
Public Property TextColor As Color

Property Value​

Color

Underline​

Gets or sets a value indicating if the label is underlined.

public bool Underline { get; set; }
Public Property Underline As Boolean

Property Value​

Boolean

VAlign​

Gets or sets the VAlign enumeration that specifies the vertical text alignment of the label.

public VAlign VAlign { get; set; }
Public Property VAlign As VAlign

Property Value​

VAlign

Width​

Gets or sets the width or the label.

public float Width { get; set; }
Public Property Width As Single

Property Value​

Single

X​

Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement)

public float X { get; set; }
Public Property X As Single

Property Value​

Single

Y​

Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement)

public float Y { get; set; }
Public Property Y As Single

Property Value​

Single

Methods​

Draw(PageWriter)​

Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement)

public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)

Parameters​

PageWriter object to receive the page element's output.

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicPDF.PageElements