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: ObjectPageElementTaggablePageElementRotatingPageElementPageNumberingLabel
Implements: IArea, ICoordinate, ISerializable
Licensing Info
This class is a DynamicPDF Core Suite Essentials feature. One of the following is required for non-evaluation usage:
- Any active DynamicPDF Subscription (Essentials, Professional, Professional Plus or Ultimate).
- A DynamicPDF Core Suite for .NET v12.X Essentials license.
- It can also be used for free with a public link back to www.dynamicpdf.com and with the DynamicPDF Essentials message displaying on the bottom of each page.
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;
public class Example
{
public static void CreatePDF(string outputPath)
{
// 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( outputPath );
}
}
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.
-
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)/%/%".
Constructors
PageNumberingLabel(String, Single, Single, Single, Single) | Initializes a new instance of the PageNumberingLabel class. |
PageNumberingLabel(String, Single, Single, Single, Single, Font) | Initializes a new instance of the PageNumberingLabel class. |
PageNumberingLabel(String, Single, Single, Single, Single, Font, Single) | Initializes a new instance of the PageNumberingLabel class. |
PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, Color) | Initializes a new instance of the PageNumberingLabel class. |
PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, TextAlign) | Initializes a new instance of the PageNumberingLabel class. |
PageNumberingLabel(String, Single, Single, Single, Single, Font, Single, TextAlign, Color, [Optional] Boolean) | Initializes a new instance of the PageNumberingLabel class. |
Properties
Align | Gets or sets the Align enumeration that specifies the text alignment of the label. |
Angle | Gets or sets the heights of the angle element. (Inherited from RotatingPageElement) |
Font | Gets or sets the Font object to use for the text of the label. |
FontSize | Gets or sets the font size for the text of the label. |
Height | Gets or sets the heights of the page element. (Inherited from RotatingPageElement) |
ID | Gets or sets the ID of the page element. (Inherited from PageElement) |
IgnoreMargins | Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement) |
NumberingLength | Gets or sets the length of the page numbering label. |
NumberingPaddingCharacter | Gets or sets the padding character of the page numbering label. |
PageOffset | Gets or sets the page offset for page numbering. |
PageTotalOffset | Gets or sets the page total offset for page numbering. |
RelativeTo | Gets and sets placement of the page element on the page. (Inherited from PageElement) |
RightToLeft | Gets or sets a value indicating if text should be displayed right to left. |
Tag | Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement) |
TagOrder | Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement) |
Text | Gets or sets the text of the label. |
TextColor | Gets or sets the Color object to use for the text of the label. |
Underline | Gets or sets a value indicating if the label is underlined. |
VAlign | Gets or sets the VAlign enumeration that specifies the vertical text alignment of the label. |
Width | Gets or sets the width or the label. |
X | Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement) |
Y | Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement) |
Methods
Draw(PageWriter) | Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement) |
Equals(Object) | Determines whether the specified Object is equal to the current Object . (Inherited from Object) |
GetHashCode() | Serves as a hash function for a particular type. (Inherited from Object) |
GetType() | Gets the Type of the current instance. (Inherited from Object) |
ToString() | Returns a String that represents the current Object . (Inherited from Object) |