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

com.dynamicpdf.api.elements.TextElement 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.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Represents a text element.
 * 
 * 

This class can be used to place text on a page.

*/ @JsonInclude(Include.NON_DEFAULT) @JsonAutoDetect(fieldVisibility = Visibility.NON_PRIVATE) public class TextElement extends Element { private Color color; private Font font; private String fontName; private Resource resource; private String colorName; private float fontSize; /** * Initializes a new instance of the TextElement class * * @param value Text to display in the text element. * @param placement The placement of the text element on the page. * @param xOffset X coordinate of the text element. * @param yOffset Y coordinate of the text element. */ public TextElement(String value, ElementPlacement placement, float xOffset, float yOffset) { super(value, placement, xOffset, yOffset); } /** * Initializes a new instance of the TextElement class * * @param value Text to display in the text element. * @param xOffset X coordinate of the text element. * @param yOffset Y coordinate of the text element. */ public TextElement(String value, float xOffset, float yOffset) { super(value, ElementPlacement.TOPLEFT, xOffset, yOffset); } /** * Initializes a new instance of the TextElement class * * @param value Text to display in the text element. * @param placement The placement of the text element on the page. */ public TextElement(String value, ElementPlacement placement) { this(value, placement, 0, 0); } /** * Initializes a new instance of the TextElement class * * @param value Text to display in the text element. */ public TextElement(String value) { this(value, ElementPlacement.TOPLEFT, 0, 0); } @JsonProperty("type") ElementType getType() { return ElementType.TEXT; } @JsonProperty("font") String getFontName() { return fontName; } void setFontName(String value) { fontName = value; } @JsonProperty("color") String getColorName() { return colorName; } void setColorName(String value) { colorName = value; } /** *

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; } /** * Gets the text to display in the text element. * @return The text to display in the text element. */ public String getText() { return getInputValue(); } /** * Sets the text to display in the text element. * @param value The text to display in the text element. */ public void setText(String value) { setInputValue(value); } /** * Gets the Color object to use for the text of the text element. * @return The Color object to use for the text of the text element. */ @JsonIgnore public Color getColor() { return color; } /** * Sets the Color object to use for the text of the text element. * @param value The Color object to use for the text of the text element. */ public void setColor(Color value) { color = value; colorName = color.getColorString(); } /** * Gets the Font object used to specify the font of the text for the text element. * @return The Font object used to specify the font of the text for the text element. */ @JsonIgnore public Font getFont() { return font; } /** * Sets the Font object used to specify the font of the text for the text element. * @param value The Font object used to specify the font of the text for the text element. */ public void setFont(Font value) { font = value; fontName = font.getName(); resource = font.getResource(); } /** * Gets the font size for the text of the text element. * @return The font size for the text of the text element. */ @JsonSerialize(using = FloatJsonSerializer.class) public float getFontSize() { return fontSize; } /** * Sets the font size for the text of the text element. * @param value The font size for the text of the text element. */ public void setFontSize(float value) { fontSize = value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy