Class PageNumberingElement

java.lang.Object
com.dynamicpdf.api.elements.Element
com.dynamicpdf.api.elements.PageNumberingElement

public class PageNumberingElement extends Element
Represents a page numbering label page element.

This class can be used to add page numbering to a PDF document. 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.

TokenDescription
CPCurrent page. The default numbering style is numeric.
TPTotal pages. The default numbering style is numeric.
SPSection page.
STSection Total.
PRPrefix.

All tokens except the %%PR%% token can also contain a numbering style specifier. The numbering style specifier is placed in parenthesis after the token.

Numbering StyleDescription
1Numeric. Arabic numbers are used: 1, 2, 3, etc. Example: "%%CP(1)%%"
iLower Case Roman Numerals. Lower case roman numerals are used: i, ii, iii, etc. Example: "%%CP(i)%%".
IUpper Case Roman Numerals. Upper case roman numerals are used: I, II, III, etc. Example: "%%CP(I)%%".
aLower Latin Letters. Lower case Latin letters are used: a, b, c, etc. After z, aa is used followed by bb, cc, ect. Example: "%%CP(a)%%".
AUpper Latin Letters. Upper case Latin letters are used: A, B, C, etc. After Z, AA is used followed by BB, CC, ect. Example: "%%CP(A)%%".
bLower Latin Letters. Lower case Latin letters are used: a, b, c, etc. After z, aa is used followed by ab, ac, ect. Example: "%%CP(b)%%".
BLower Latin Letters. Lower case Latin letters are used: A, B, C, etc. After Z, AA is used followed by AB, AC, ect. 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)%%

  • Constructor Details

    • PageNumberingElement

      public PageNumberingElement(String text, ElementPlacement placement, float xOffset, float yOffset)
      Initializes a new instance of the PageNumberingElement class.
      Parameters:
      text - Text to display in the label.
      placement - The placement of the page numbering element on the page.
      xOffset - X coordinate of the label.
      yOffset - Y coordinate of the label.
    • PageNumberingElement

      public PageNumberingElement(String text, ElementPlacement placement)
      Initializes a new instance of the PageNumberingElement class.
      Parameters:
      text - Text to display in the label.
      placement - The placement of the page numbering element on the page.
  • Method Details

    • getResource

      public Resource getResource()
      Overrides:
      getResource in class Element
    • getTextFont

      public Font getTextFont()
      Overrides:
      getTextFont in class Element
    • getColor

      public Color getColor()
      Gets the Color object to use for the text of the label
      Returns:
      The Color object to use for the text of the label
    • setColor

      public void setColor(Color value)
      Sets the Color object to use for the text of the label
      Parameters:
      value - The Color object to use for the text of the label
    • getFont

      public Font getFont()
      Gets the Font object to use for the text of the label.
      Returns:
      The Font object to use for the text of the label.
    • setFont

      public void setFont(Font value)
      Sets the Font object to use for the text of the label.
      Parameters:
      value - The Font object to use for the text of the label.
    • getFontSize

      public float getFontSize()
      Gets the font size for the text of the label.
      Returns:
      The font size for the text of the label.
    • setFontSize

      public void setFontSize(float value)
      Sets the font size for the text of the label.
      Parameters:
      value - The font size for the text of the label.
    • getText

      public String getText()
      Gets the text to display in the label.
      Returns:
      The text to display in the label.
    • setText

      public void setText(String value)
      Sets the text to display in the label.
      Parameters:
      value - The text to display in the label.