public final class TextParagraph extends Object
Represents text paragraphs as multiline text object.
The example demonstrates how to create text paragraph object and append it to the Pdf page. Document doc = new Document(inFile); Page page = (Page)doc.getPages().get(1); // create text paragraph TextParagraph paragraph = new TextParagraph(); // set the paragraph rectangle paragraph.setRectangle ( new Rectangle(100, 600, 200, 700)); // set word wrapping options paragraph.getFormattingOptions().setWrapMode ( TextFormattingOptions.WordWrapMode.ByWords); // append string lines paragraph.appendLine("the quick brown fox jumps over the lazy dog"); paragraph.appendLine("line2"); paragraph.appendLine("line3"); // append the paragraph to the Pdf page with the TextBuilder TextBuilder textBuilder = new TextBuilder(page); textBuilder.appendParagraph(paragraph); // save Pdf document doc.save(outFile);
Modifier and Type | Class and Description |
---|---|
static class |
TextParagraph.TextBackgroundMode
Background mode for TextParagraph
|
Constructor and Description |
---|
TextParagraph()
Creates
TextParagraph object. |
Modifier and Type | Method and Description |
---|---|
void |
appendLine(String line)
Appends text line
|
void |
appendLine(String line,
float lineSpacing)
Appends text line.
|
void |
appendLine(String line,
TextState textState)
Appends text line with text state parameters.
|
void |
appendLine(String line,
TextState textState,
float lineSpacing)
Appends text line with text state parameters
|
void |
appendLine(TextFragment line)
Appends text line with text state parameters.
|
void |
appendLine(TextFragment line,
TextState textState)
Appends text line with text state parameters.
|
void |
appendLine(TextFragment line,
TextState textState,
float lineSpacing)
Appends text line with text state parameters
|
void |
beginEdit()
Begins the editing of the TextParagraph.
|
void |
endEdit()
Ends the editing of the TextParagraph.
|
float |
getFirstLineIndent()
Gets or sets subsequent lines indent value.
|
TextFormattingOptions |
getFormattingOptions()
Gets formatting options.
|
int |
getHorizontalAlignment()
Gets horizontal alignment for the text inside paragrph's Rectangle.
|
MarginInfo |
getMargin()
Gets the padding.
|
Position |
getPosition()
Gets position of the paragraph.
|
Rectangle |
getRectangle()
Gets rectangle of the paragraph.
|
double |
getRotation()
Gets or sets rotation angle in degrees.
|
float |
getSubsequentLinesIndent()
Gets subsequent lines indent value.
|
Rectangle |
getTextRectangle()
Gets rectangle of the text placed to the paragraph.
|
int |
getVerticalAlignment()
Gets vertical alignment for the text inside paragrph's
Rectangle . |
boolean |
isJustify()
Gets value whether text is justified.
|
void |
setBackgroundColor(Color value)
Sets background color for the text paragraph.
|
void |
setBackgroundMode(int value)
Set background mode for the text paragraph
|
void |
setFirstLineIndent(float value)
Gets or sets subsequent lines indent value.
|
void |
setFormattingOptions(TextFormattingOptions value)
Sets formatting options.
|
void |
setHorizontalAlignment(int value)
Sets horizontal alignment for the text inside paragrph's Rectangle.
|
void |
setJustify(boolean value)
Sets value whether text is justified.
|
void |
setMargin(MarginInfo value)
Sets the padding.
|
void |
setMatrix(Matrix value)
Sets Rotation of the paragraph.
|
void |
setOldCodeCompatibilityMode(boolean value)
Set old code compatibility mode
|
void |
setPosition(Position value)
Sets position of the paragraph.
|
void |
setRectangle(Rectangle value)
Sets rectangle of the paragraph.
|
void |
setRotation(double value)
Gets or sets rotation angle in degrees.
|
void |
setSubsequentLinesIndent(float value)
Sets subsequent lines indent value.
|
void |
setVerticalAlignment(int value)
Sets vertical alignment for the text inside paragrph's
Rectangle . |
public void setBackgroundColor(Color value)
Sets background color for the text paragraph.
value
- Color objectpublic int getVerticalAlignment()
Gets vertical alignment for the text inside paragrph's Rectangle
.
VerticalAlignment.None is equal to VerticalAlignment.Bottom.
public void setVerticalAlignment(int value)
Sets vertical alignment for the text inside paragrph's Rectangle
.
VerticalAlignment.None is equal to VerticalAlignment.Bottom.
value
- VerticalAlignment valueVerticalAlignment
public float getSubsequentLinesIndent()
Gets subsequent lines indent value.
public void setSubsequentLinesIndent(float value)
Sets subsequent lines indent value.
value
- float valuepublic final float getFirstLineIndent()
Gets or sets subsequent lines indent value. If set to a non-zero value, it has an advantage over the FormattingOptions.SubsequentLinesIndent value.
public final void setFirstLineIndent(float value)
Gets or sets subsequent lines indent value. If set to a non-zero value, it has an advantage over the FormattingOptions.SubsequentLinesIndent value.
value
- float valuepublic boolean isJustify()
Gets value whether text is justified.
public void setJustify(boolean value)
Sets value whether text is justified.
value
- boolean valuepublic int getHorizontalAlignment()
HorizontalAlignment.None is equal to HorizontalAlignment.Left.
HorizontalAlignment
public void setHorizontalAlignment(int value)
Sets horizontal alignment for the text inside paragrph's Rectangle.
HorizontalAlignment.None is equal to HorizontalAlignment.Left.
value
- HorizontalAlignment valueHorizontalAlignment
public TextFormattingOptions getFormattingOptions()
Gets formatting options.
public void setFormattingOptions(TextFormattingOptions value)
Sets formatting options.
value
- TextFormattingOptions objectpublic Position getPosition()
Gets position of the paragraph.
public void setPosition(Position value)
Sets position of the paragraph.
value
- Position valuepublic Rectangle getTextRectangle()
Gets rectangle of the text placed to the paragraph.
public Rectangle getRectangle()
Gets rectangle of the paragraph.
public void setRectangle(Rectangle value)
Sets rectangle of the paragraph.
value
- Rectangle objectpublic MarginInfo getMargin()
Gets the padding.
public void setMargin(MarginInfo value)
Sets the padding.
value
- MarginInfo valuepublic double getRotation()
Gets or sets rotation angle in degrees.
public void setRotation(double value)
Gets or sets rotation angle in degrees.
value
- double valuepublic void beginEdit()
Improves performance of TextParagraph population. Any layout calculation is suspended until EndEdit method is invoked.
Note that method invoke can't be nested.
public void endEdit()
Improves performance of TextParagraph population. Any layout calculation is suspended until EndEdit method is invoked.
Note that method invoke can't be nested.
public void appendLine(String line)
Appends text line
line
- The new line's text.public void appendLine(String line, float lineSpacing)
Appends text line.
line
- The new line's text.lineSpacing
- Additional spacing (0.0 is default and corresponds to default text line height). The spacing
value is added to default line spacing for the particular line, so you may specify 12.0 to
get empty row AFTER a text line drawn with 12pt font.public void appendLine(String line, TextState textState)
Appends text line with text state parameters.
line
- The new line's text.textState
- Text state of the new line.public void appendLine(String line, TextState textState, float lineSpacing)
Appends text line with text state parameters
line
- The new line's text.textState
- Text state of the new line.lineSpacing
- Additional spacing (0.0 is default and corresponds to default text line height). The spacing
value is added to default line spacing for the particular line, so you may specify 12.0 to
get empty row AFTER a text line drawn with 12pt font.public void appendLine(TextFragment line)
Appends text line with text state parameters.
line
- The new line's text.public void appendLine(TextFragment line, TextState textState)
Appends text line with text state parameters.
line
- The new line's text.textState
- Text state of the new line.public void appendLine(TextFragment line, TextState textState, float lineSpacing)
Appends text line with text state parameters
line
- The new line's text.textState
- Text state of the new line.lineSpacing
- Additional spacing (0.0 is default and corresponds to default text line height). The spacing
value is added to default line spacing for the particular line, so you may specify 12.0 to
get empty row AFTER a text line drawn with 12pt font.public void setMatrix(Matrix value)
Sets Rotation of the paragraph.
value
- Matrix objectpublic void setOldCodeCompatibilityMode(boolean value)
Set old code compatibility mode
value
- boolean valuepublic void setBackgroundMode(int value)
Set background mode for the text paragraph
value
- int valueTextParagraph.TextBackgroundMode