public class PdfTextFormatter extends Object implements Cloneable
PdfPage
objects. An object of this class is returned when
getTextFormatter
method is used on a PdfPage
object. Formatting settings specified on the
PdfTextFormatter
object will affect subsequent calls
to writeText
method for the page.
The text formatting attributes supported by this class are as follows:
An object of the PdfTextFormatter
class has the
following settings as default:
Modifier and Type | Field and Description |
---|---|
static int |
CENTER
Constant to align text to center.
|
static int |
HORIZONTAL |
static int |
JUSTIFIED
Constant to align text to both left and right margins.
|
static int |
LEFT
Constant to align text to left margin.
|
static int |
LEFT_TO_RIGHT |
static boolean |
NO_WRAP
Constant to prevent text wrapping.
|
static int |
RIGHT
Constant to align text to right margin.
|
static int |
RIGHT_TO_LEFT |
static int |
VERTICAL |
static boolean |
WRAP
Constant to wrap text.
|
Constructor and Description |
---|
PdfTextFormatter()
Zero-argument default constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
int |
getAlignment()
Retrieves text alignment.
|
double |
getCharSpacing() |
int |
getDirection() |
double |
getFirstLinePosition()
Retrieves default position where first line of text is set to
be written inside rectangles.
|
double |
getHorizontalScaling() |
double |
getLineSpacing() |
double |
getRise()
Deprecated.
|
double |
getScaling()
Deprecated.
|
double |
getWordSpacing() |
int |
getWritingMode() |
boolean |
isJustifyLastLine()
Retrieves whether last line is aligned to both left and right
margins.
|
boolean |
isWrap()
Retrieves whether text is set to wrap.
|
void |
setAlignment(int alignment)
Specifies text alignment.
|
void |
setCharSpacing(double charSpacing) |
void |
setDirection(int direction) |
void |
setFirstLinePosition(double firstLinePosition)
Specifies default position where first line of text should be
written inside rectangles.
|
void |
setHorizontalScaling(double horizontalScaleInPercentage) |
void |
setJustifyLastLine(boolean justifyLastLine)
Specifies whether last line should be aligned to both left and
right margins.
|
void |
setLineSpacing(double lineSpacing) |
void |
setRise(double rise)
Deprecated.
|
void |
setScaling(double scaling)
Deprecated.
|
void |
setWordSpacing(double wordSpacing) |
void |
setWrap(boolean wrap)
Specifies whether text should wrap.
|
void |
setWritingMode(int writingMode) |
public static final boolean WRAP
public static final boolean NO_WRAP
public static final int LEFT
public static final int RIGHT
public static final int CENTER
public static final int JUSTIFIED
public static final int HORIZONTAL
public static final int VERTICAL
public static final int LEFT_TO_RIGHT
public static final int RIGHT_TO_LEFT
public int getAlignment()
setAlignment(int)
public void setAlignment(int alignment)
alignment
- constant specifying text alignmentgetAlignment()
public double getCharSpacing()
public void setCharSpacing(double charSpacing)
public int getDirection()
public void setDirection(int direction)
public double getLineSpacing()
public void setLineSpacing(double lineSpacing)
public double getRise()
public void setRise(double rise)
public double getScaling()
public void setScaling(double scaling)
public double getHorizontalScaling()
public void setHorizontalScaling(double horizontalScaleInPercentage)
public double getWordSpacing()
public void setWordSpacing(double wordSpacing)
public boolean isWrap()
setWrap(boolean)
public void setWrap(boolean wrap)
public int getWritingMode()
public void setWritingMode(int writingMode)
public double getFirstLinePosition()
setFirstLinePosition(double)
public void setFirstLinePosition(double firstLinePosition)
firstLinePosition
must be less than the total width of the rectangle. Else, the
first line defaults to the first position on the second line.firstLinePosition
- default position inside rectangles where the first
line of text should begin (Applied in current
measurement unit)getFirstLinePosition()
public boolean isJustifyLastLine()
true
if last line is aligned to both left
and right margins.
false
if otherwise.setJustifyLastLine(boolean)
public void setJustifyLastLine(boolean justifyLastLine)
justifyLastLine
- true
aligns last line text to both left and
right margins.
false
defaults the alignment to the left
margin.isJustifyLastLine()