All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dynamicpdf.api.elements.PageNumberingElement Maven / Gradle / Ivy

Go to download

A Java Client API that uses the DynamicPDF API to create, merge, split, form fill, stamp, secure/encrypt PDF documents.

There is a newer version: 1.10.1
Show newest version
package com.dynamicpdf.api.elements;

import com.dynamicpdf.api.Color;
import com.dynamicpdf.api.FloatJsonSerializer;
import com.dynamicpdf.api.Font;
import com.dynamicpdf.api.Resource;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 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.

* *

* * * * * * * * * * * *
The following table shows how to use the tokens
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.

* * * * * * * * * * * * * * * * * * *
The following table shows the Numbering Styles
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)%%
  • *
*/ @JsonInclude(Include.NON_DEFAULT) @JsonAutoDetect(fieldVisibility = Visibility.NON_PRIVATE) public class PageNumberingElement extends Element { private Color color; private Font font; private Resource resource; private String fontName; private String colorName; private float fontSize; /** * Initializes a new instance of the PageNumberingElement class. * * @param text Text to display in the label. * @param placement The placement of the page numbering element on the page. * @param xOffset X coordinate of the label. * @param yOffset Y coordinate of the label. */ public PageNumberingElement(String text, ElementPlacement placement, float xOffset, float yOffset) { super(text, placement, xOffset, yOffset); } /** * Initializes a new instance of the PageNumberingElement class. * * @param text Text to display in the label. * @param xOffset X coordinate of the label. * @param yOffset Y coordinate of the label. */ public PageNumberingElement(String text, float xOffset, float yOffset) { super(text, ElementPlacement.TOPLEFT, xOffset, yOffset); } /** * Initializes a new instance of the PageNumberingElement class. * * @param text Text to display in the label. * @param placement The placement of the page numbering element on the page. */ public PageNumberingElement(String text, ElementPlacement placement) { this(text, placement, 0, 0); } /** * Initializes a new instance of the PageNumberingElement class. * * @param text Text to display in the label. */ public PageNumberingElement(String text) { this(text, ElementPlacement.TOPLEFT, 0, 0); } @JsonProperty("type") ElementType getType() { return ElementType.PAGENUMBERING; } /** *

This method is meant for DynamicPDF's internal usage and not supposed to be used by the client programs.

*/ @JsonIgnore public Resource getResource() { return resource; } void setResource(Resource value) { resource = value; } /** *

This method is meant for DynamicPDF's internal usage and not supposed to be used by the client programs.

*/ @JsonIgnore public Font getTextFont() { return font; } @JsonProperty("font") String getFontName() { return fontName; } void setFontName(String value) { fontName = value; } @JsonProperty("color") String getColorName() { return colorName; } void setColorName(String value) { colorName = value; } /** * Gets the Color object to use for the text of the label * @return The Color object to use for the text of the label */ @JsonIgnore public Color getColor() { return color; } /** * Sets the Color object to use for the text of the label * @param value The Color object to use for the text of the label */ public void setColor(Color value) { color = value; colorName = value.getColorString(); } /** * Gets the Font object to use for the text of the label. * @return The Font object to use for the text of the label. */ @JsonIgnore public Font getFont() { return font; } /** * Sets the Font object to use for the text of the label. * @param value The Font object to use for the text of the label. */ public void setFont(Font value) { font = value; fontName = font.getName(); resource = font.getResource(); } /** * Gets the font size for the text of the label. * @return The font size for the text of the label. */ @JsonSerialize(using = FloatJsonSerializer.class) public float getFontSize() { return fontSize; } /** * Sets the font size for the text of the label. * @param value The font size for the text of the label. */ public void setFontSize(float value) { fontSize = value; } /** * Gets the text to display in the label. * @return The text to display in the label. */ public String getText() { return getInputValue(); } /** * Sets the text to display in the label. * @param value The text to display in the label. */ public void setText(String value) { setInputValue(value); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy