cete.dynamicpdf.pageelements.pagenumberinglabel
PageNumberingLabel
- Namespace: ceTe.DynamicPDF.PageElements
- Assemblies: ceTe.DynamicPDF.40.dll
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- textColor: Color
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- align: TextAlign
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: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- align: TextAlign
Alignment of the text of the label.
- textColor: Color
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
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
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
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
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
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
PageOffset
Gets or sets the page offset for page numbering.
public int PageOffset { get; set; }
Public Property PageOffset As Int32
Property Value
PageTotalOffset
Gets or sets the page total offset for page numbering.
public int PageTotalOffset { get; set; }
Public Property PageTotalOffset As Int32
Property Value
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
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
Text
Gets or sets the text of the label.
public string Text { get; set; }
Public Property Text As String
Property Value
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
Underline
Gets or sets a value indicating if the label is underlined.
public bool Underline { get; set; }
Public Property Underline As Boolean
Property Value
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
Width
Gets or sets the width or the label.
public float Width { get; set; }
Public Property Width As Single
Property Value
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
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
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
- writer: PageWriter
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
- obj: Object
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 .