ElegantJ PDF Library Java API Specification v1.1

com.elegantj.pdf
Class PDFText

java.lang.Object
  extended bycom.elegantj.pdf.PDFObject
      extended bycom.elegantj.pdf.PDFGraphicsObject
          extended bycom.elegantj.pdf.PDFText

public class PDFText
extends PDFGraphicsObject

This class represents PDF Text object


Field Summary
static int CENTER
          Possible value for the text's alignment
static int JUSTIFY
          Possible value for the text's alignment
static int LEFT
          Possible value for the text's alignment
static int RIGHT
          Possible value for the text's alignment
 
Fields inherited from class com.elegantj.pdf.PDFGraphicsObject
BEVEL_JOINS, BUTT_CAPS, MITER_JOINS, ROUND_CAPS, ROUND_JOINS, SQUARE_CAPS
 
Constructor Summary
PDFText(java.lang.String text)
          Constructs the PDFText with the specified text It will draw the text to the rectangle made by media box and the left alignment will be considered
PDFText(java.lang.String text, int x, int y)
          Constructs the PDFText with the specified text It will draw the text to the rectangle made by x, y and mediabox's width and height and the left alignment will be considered
PDFText(java.lang.String text, int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY)
          Constructs the PDFText with the specified text
PDFText(java.lang.String text, int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY, int alignment)
          Constructs the PDFText with the specified text
 
Method Summary
 java.lang.Object clone()
          Returns the clone of this object
 int getAlignment()
          Returns the alignment for the PDFText
 int getCharSpacing()
          Method which returns the value of character spacing of this PDFText object
 int getFontSize()
          Method which returns the font size of this PDFText object
 int getHorizontalScaling()
          Method which returns the value of horizontal scaling of this PDFText object
 int getIndent()
          Returns the indent for the PDFText i.e.
 int getLastY()
          Returns the last Y coordinate of the page after adding the this text to the page
this value is useful in case of
case1 : If the less text given than the area of the the rectangle build
by the upperLeftX, upperLeftY, lowerRightX and lowerRigghtY.
case2 : If the upperLeftX, upperLeftY, lowerRightX and lowerRightY not supplied during the PDFText object creation
case3 : If the only upperLeftX and upperLeftY have been supplied during the PDFText object creation
 int getLowerRightX()
          Method which returns the lower right X coordinate value for this PDFText object
 int getLowerRightY()
          Method which returns the lower right Y coordinate value for this PDFText object
 PDFPattern getPattern()
          Returns the PDFPattern which is used to fill to this object
 PDFFont getPDFFont()
          Method which returns the font of this PDFText object
 int getRise()
          Method which returns the value of text rise of this PDFText object Text rise specifies the amount, to move the baseline up or down from its default location.
 int getStringWidth(java.lang.String text)
          Returns the string width including the charSpacing, wordSpacing, horizontalScaling accroding to the current font of the PDFText and Font size
 java.lang.String getText()
          Method which returns the string representing the text for this PDFText object
 int getUpperLeftX()
          Method which returns the upper left X coordinate value for this PDFText object
 int getUpperLeftY()
          Method which returns the upper left Y coordinate value for this PDFText object
 int getWordSpacing()
          Method which returns the value of word spacing of this PDFText object
 boolean isOutlineMode()
          Method which returns the state of StrokeMode of this PDFText object When StrokeMode is on, the text will be drawn along with stroke color outline
 boolean isStrikeOut()
          Returns the, wheather strike out is allowed to the PDFText
 boolean isUnderLine()
          Returns the, wheather under line is allowed to the PDFText
 boolean isWrapStyleWord()
          Method which returns the wheather wrapping to the PDFText is allowed or not
 java.lang.String ligaturize(java.lang.String inStr)
          As per Locale perform operation on given string and return processed string
 java.lang.String reverseString(java.lang.String str, java.util.Vector charset)
          Reverse characters in given string and return new String if Arabic character found in given charset vector
 void setAlignment(int alignment)
          Sets the alignment for the PDFText
 void setCharSpacing(int n)
          Method which set the value of character spacing for this PDFText object
 void setFillColor(java.awt.Color fillColor)
          Method which sets the fill color of text for this PDFText object
 void setFontSize(int size)
          Method which sets the font size for this PDFText object
 void setHorizontalScaling(int n)
          Method which set the value of horizontal scaling for this PDFText object
 void setIndent(int indent)
          Sets the indent for the PDFText i.e.
 void setLowerRightX(int x)
          Method which sets the lower right X coordinate value for this PDFText object
 void setLowerRightY(int y)
          Method which sets the lower right Y coordinate value for this PDFText object
 void setOutlineColor(java.awt.Color outLineColor)
          Method which sets the outline color of text for this PDFText object Stroke color is used to fill text outlines
 void setOutlineMode(boolean flag)
          Method which sets the OutlineMode for the text for this PDFText object When OutlineMode is on, the text will be drawn along with outline color outline
 void setPattern(PDFPattern pattern)
          Sets the PDFPattern to fill this object
 void setPDFFont(PDFFont f)
          Method which sets the font for this PDFText object
 void setRise(int n)
          Method which set the value of text rise for this PDFText object Text rise specifies the amount, to move the baseline up or down from its default location.
 void setStrikeOut(boolean isStrikeOut)
          Sets the, wheather strike out is allowed to the PDFText
 void setText(java.lang.String text)
          Method which sets the text for this PDFText object
 void setUnderLine(boolean isUnderLine)
          Sets the, wheather under line is allowed to the PDFText
 void setUpperLeftX(int x)
          Method which sets the upper left X coordinate value for this PDFText object
 void setUpperLeftY(int y)
          Method which sets the upper left Y coordinate value for this PDFText object
 void setWordSpacing(int n)
          Method which set the value of word spacing for this PDFText object
 void setWrapStyleWord(boolean isWrapStyleWord)
          Method which sets the wheather wrapping to the PDFText is allowed or not The default value for this property is true
 
Methods inherited from class com.elegantj.pdf.PDFObject
getPDFObjectID, getPDFObjectRefStr, getPDFObjectType, setPDFObjectID, setPDFObjectType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Possible value for the text's alignment

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Possible value for the text's alignment

See Also:
Constant Field Values

CENTER

public static final int CENTER
Possible value for the text's alignment

See Also:
Constant Field Values

JUSTIFY

public static final int JUSTIFY
Possible value for the text's alignment

See Also:
Constant Field Values
Constructor Detail

PDFText

public PDFText(java.lang.String text)
Constructs the PDFText with the specified text It will draw the text to the rectangle made by media box and the left alignment will be considered

Parameters:
text - The specified Text, If the specified text contains new line characters like '\r' or '\n' the new line character will be appended to the PDF, i.e. the next line will be drawn to the next line, If the specified text's length will go out of rectangle width, then line will be wrapped if the wrapStyleWord is true, i.e. it draws only characters which are fit to the rectangle width and the remaining characters will be appeared in the next line

PDFText

public PDFText(java.lang.String text,
               int x,
               int y)
Constructs the PDFText with the specified text It will draw the text to the rectangle made by x, y and mediabox's width and height and the left alignment will be considered

Parameters:
text - The specified Text If the specified text contains new line characters like '\r' or '\n' the new line character will be appended to the PDF, i.e. the next line will be drawn to the new line in PDF, If the specified text's length will go out of rectangle width, then line will be wrapped, i.e. it draws only characters which are fit to the rectangle width and the remaining characters will be appeared in the next line
x - The x coordinate, from where text drawn will be started
y - The y coordinate, from where text drawn will be started

PDFText

public PDFText(java.lang.String text,
               int upperLeftX,
               int upperLeftY,
               int lowerRightX,
               int lowerRightY)
Constructs the PDFText with the specified text

Parameters:
text - The specified Text If the specified text contains new line characters like '\r' or '\n' the new line character will be appended to the PDF, i.e. the next line will be drawn to the new line in PDF, If the specified text's length will go out of rectangle width, then line will be wrapped, i.e. it draws only characters which are fit to the rectangle width and the remaining characters will be appeared in the next line
upperLeftX - The upper left X coordinate of the Box in which text will be drawn
upperLeftY - The upper left Y coordinate of the Box in which text will be drawn
lowerRightX - The lower right X coordinate of the Box in which text will be drawn
lowerRightY - The lower right Y coordinate of the Box in which text will be drawn default alignment for the text is left will be considered

PDFText

public PDFText(java.lang.String text,
               int upperLeftX,
               int upperLeftY,
               int lowerRightX,
               int lowerRightY,
               int alignment)
Constructs the PDFText with the specified text

Parameters:
text - The specified Text If the specified text contains new line characters like '\r' or '\n' the new line character will be appended to the PDF, i.e. the next line will be drawn to the new line in PDF, If the specified text's length will go out of rectangle width, then line will be wrapped, i.e. it draws only characters which are fit to the rectangle width and the remaining characters will be appeared in the next line
upperLeftX - The upper left X coordinate of the Box in which text will be drawn
upperLeftY - The upper left Y coordinate of the Box in which text will be drawn
lowerRightX - The lower right X coordinate of the Box in which text will be drawn
lowerRightY - The lower right Y coordinate of the Box in which text will be drawn
alignment - The alignment for the PDFText, The possible values are LEFT, RIGHT, CENTER and JUSTIFY
Method Detail

setText

public void setText(java.lang.String text)
Method which sets the text for this PDFText object

Parameters:
text - The string representing the text

getText

public java.lang.String getText()
Method which returns the string representing the text for this PDFText object

Returns:
The string representing the text

setWrapStyleWord

public void setWrapStyleWord(boolean isWrapStyleWord)
Method which sets the wheather wrapping to the PDFText is allowed or not The default value for this property is true

Parameters:
isWrapStyleWord - wheather wrapping to the PDFText is allowed or not

isWrapStyleWord

public boolean isWrapStyleWord()
Method which returns the wheather wrapping to the PDFText is allowed or not

Returns:
wheather wrapping to the PDFText is allowed or not

setAlignment

public void setAlignment(int alignment)
Sets the alignment for the PDFText

Parameters:
alignment - The specified alignment The possible values are LEFT, CENTER, RIGHT, JUSTIFY Default is LEFT alignment

getAlignment

public int getAlignment()
Returns the alignment for the PDFText

Returns:
The alignment for the PDFText The possible values are LEFT, CENTER, RIGHT, JUSTIFY Default is LEFT alignment

setUpperLeftX

public void setUpperLeftX(int x)
Method which sets the upper left X coordinate value for this PDFText object

Parameters:
x - The uppre left X coordinate

getUpperLeftX

public int getUpperLeftX()
Method which returns the upper left X coordinate value for this PDFText object

Returns:
The uppre left X coordinate

setUpperLeftY

public void setUpperLeftY(int y)
Method which sets the upper left Y coordinate value for this PDFText object


getUpperLeftY

public int getUpperLeftY()
Method which returns the upper left Y coordinate value for this PDFText object

Returns:
The uppre left Y coordinate

setLowerRightX

public void setLowerRightX(int x)
Method which sets the lower right X coordinate value for this PDFText object

Parameters:
x - The lower right X coordinate

getLowerRightX

public int getLowerRightX()
Method which returns the lower right X coordinate value for this PDFText object

Returns:
The lower right X coordinate

setLowerRightY

public void setLowerRightY(int y)
Method which sets the lower right Y coordinate value for this PDFText object

Parameters:
y - The lower right Y coordinate

getLowerRightY

public int getLowerRightY()
Method which returns the lower right Y coordinate value for this PDFText object

Returns:
The lower right Y coordinate

setIndent

public void setIndent(int indent)
Sets the indent for the PDFText i.e. the no of pixels to be left for the first line of this PDFText object This no of pixels have been left to make the paragraph

Parameters:
indent - The specified value of the indent The default value is 0 The indent value must be less than the specified PDFText width It works only with the alignment LEFT and JUSTIFY

getIndent

public int getIndent()
Returns the indent for the PDFText i.e. the no of pixels to be left for the first line of this PDFText object This no of pixels have been left to make the paragraph The default value is 0

Returns:
indent The value of the indent The indent value must be less than the specified PDFText width It works only with the alignment LEFT and JUSTIFY

setCharSpacing

public void setCharSpacing(int n)
Method which set the value of character spacing for this PDFText object

Parameters:
n - The value of character spacing If the alignment is JUSTIFY then this not working

getCharSpacing

public int getCharSpacing()
Method which returns the value of character spacing of this PDFText object

Returns:
The value of character spacing

setWordSpacing

public void setWordSpacing(int n)
Method which set the value of word spacing for this PDFText object

Parameters:
n - The value of word spacing If the alignment is JUSTIFY then this not working

getWordSpacing

public int getWordSpacing()
Method which returns the value of word spacing of this PDFText object

Returns:
The value of word spacing

setHorizontalScaling

public void setHorizontalScaling(int n)
Method which set the value of horizontal scaling for this PDFText object

Parameters:
n - The value of horizontal scaling If the alignment is JUSTIFY then this not working

getHorizontalScaling

public int getHorizontalScaling()
Method which returns the value of horizontal scaling of this PDFText object

Returns:
The value of horizontal scaling

setRise

public void setRise(int n)
Method which set the value of text rise for this PDFText object Text rise specifies the amount, to move the baseline up or down from its default location. Positive values of text rise move the baseline up. Adjustments to the baseline are useful for drawing superscripts or subscripts.

Parameters:
n - The value of text rise

getRise

public int getRise()
Method which returns the value of text rise of this PDFText object Text rise specifies the amount, to move the baseline up or down from its default location. Positive values of text rise move the baseline up. Adjustments to the baseline are useful for drawing superscripts or subscripts.

Returns:
The value of text rise

setPDFFont

public void setPDFFont(PDFFont f)
Method which sets the font for this PDFText object

Parameters:
f - The font for the text object

getPDFFont

public PDFFont getPDFFont()
Method which returns the font of this PDFText object


setFontSize

public void setFontSize(int size)
Method which sets the font size for this PDFText object

Parameters:
size - The font size for the text object

getFontSize

public int getFontSize()
Method which returns the font size of this PDFText object

Returns:
The font size for the text object

setFillColor

public void setFillColor(java.awt.Color fillColor)
Method which sets the fill color of text for this PDFText object

Parameters:
fillColor - The fill color of the text for this PDFText object

setOutlineColor

public void setOutlineColor(java.awt.Color outLineColor)
Method which sets the outline color of text for this PDFText object Stroke color is used to fill text outlines

Parameters:
outLineColor - The outline color of the text for this PDFText object

setOutlineMode

public void setOutlineMode(boolean flag)
Method which sets the OutlineMode for the text for this PDFText object When OutlineMode is on, the text will be drawn along with outline color outline

Parameters:
flag - Sets the state of OutlineMode

isOutlineMode

public boolean isOutlineMode()
Method which returns the state of StrokeMode of this PDFText object When StrokeMode is on, the text will be drawn along with stroke color outline

Returns:
The state of StrokeMode

setUnderLine

public void setUnderLine(boolean isUnderLine)
Sets the, wheather under line is allowed to the PDFText

Parameters:
isUnderLine - wheather under line is allowed to the PDFText

isUnderLine

public boolean isUnderLine()
Returns the, wheather under line is allowed to the PDFText


setStrikeOut

public void setStrikeOut(boolean isStrikeOut)
Sets the, wheather strike out is allowed to the PDFText

Parameters:
isStrikeOut - wheather strike out is allowed to the PDFText

isStrikeOut

public boolean isStrikeOut()
Returns the, wheather strike out is allowed to the PDFText

Returns:
wheather strike out is allowed to the PDFText

setPattern

public void setPattern(PDFPattern pattern)
Sets the PDFPattern to fill this object


getPattern

public PDFPattern getPattern()
Returns the PDFPattern which is used to fill to this object

Returns:
The PDFPattern which is used to fill to this object

getLastY

public int getLastY()
Returns the last Y coordinate of the page after adding the this text to the page
this value is useful in case of
case1 : If the less text given than the area of the the rectangle build
by the upperLeftX, upperLeftY, lowerRightX and lowerRigghtY.
case2 : If the upperLeftX, upperLeftY, lowerRightX and lowerRightY not supplied during the PDFText object creation
case3 : If the only upperLeftX and upperLeftY have been supplied during the PDFText object creation

Returns:
the last Y coordinate of the page after adding the this text to the page
To get proper value of this, call after adding the PDFText to the Page This value is mostly used during the PDFText makes the automatic wrapping, so in that case if user want to know the last Y so from knowing this lastY user can build new PDFText object from this y value easily

getStringWidth

public int getStringWidth(java.lang.String text)
Returns the string width including the charSpacing, wordSpacing, horizontalScaling accroding to the current font of the PDFText and Font size


ligaturize

public java.lang.String ligaturize(java.lang.String inStr)
As per Locale perform operation on given string and return processed string

Parameters:
inStr - the String
Returns:
String the processed string as per character Locale

reverseString

public java.lang.String reverseString(java.lang.String str,
                                      java.util.Vector charset)
Reverse characters in given string and return new String if Arabic character found in given charset vector

Parameters:
str - the String
charset - the Vector for character set

clone

public java.lang.Object clone()
Returns the clone of this object

Returns:
The clone of this object

ElegantJ PDF Library Java API Specification v1.1

For any feedback, suggestion, or query, please revert back to support@elegantjpdf.com

Copyright(c)
Elegant Microweb Technologies Pvt. Ltd.
www.elegantmicroweb.com
www.elegantjpdf.com
All Rights Reserved.