TextParagraph

Inheritance: java.lang.Object

public final class TextParagraph

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);

Constructors

ConstructorDescription
TextParagraph()Creates TextParagraph object.

Methods

MethodDescription
setBackgroundColor(Color value)Sets background color for the text paragraph.
getVerticalAlignment()Gets vertical alignment for the text inside paragrph’s Rectangle .
setVerticalAlignment(VerticalAlignment value)Sets vertical alignment for the text inside paragrph’s Rectangle .
getSubsequentLinesIndent()Gets subsequent lines indent value.
setSubsequentLinesIndent(float value)Sets subsequent lines indent value.
getFirstLineIndent()Gets or sets subsequent lines indent value.
setFirstLineIndent(float value)Gets or sets subsequent lines indent value.
isJustify()Gets value whether text is justified.
setJustify(boolean value)Sets value whether text is justified.
getHorizontalAlignment()Gets horizontal alignment for the text inside paragrph’s Rectangle.
setHorizontalAlignment(HorizontalAlignment value)Sets horizontal alignment for the text inside paragrph’s Rectangle.
getHyphenSymbol()Gets hyphen symbol that is used in hyphenation process.
setHyphenSymbol(String value)Sets hyphen symbol that is used in hyphenation process.
getFormattingOptions()Gets formatting options.
setFormattingOptions(TextFormattingOptions value)Sets formatting options.
getPosition()Gets position of the paragraph.
setPosition(Position value)Sets position of the paragraph.
getTextRectangle()Gets rectangle of the text placed to the paragraph.
getRectangle()Gets rectangle of the paragraph.
setRectangle(Rectangle value)Sets rectangle of the paragraph.
getMargin()Gets the padding.
setMargin(MarginInfo value)Sets the padding.
getRotation()Gets or sets rotation angle in degrees.
setRotation(double value)Gets or sets rotation angle in degrees.
beginEdit()Begins the editing of the TextParagraph.
endEdit()Ends the editing of the TextParagraph.
appendLine(String line)Appends text line
appendLine(String line, float lineSpacing)Appends text line.
appendLine(String line, TextState textState)Appends text line with text state parameters.
appendLine(String line, TextState textState, float lineSpacing)Appends text line with text state parameters
appendLine(TextFragment line)Appends text line with text state parameters.
appendLine(TextFragment line, TextState textState)Appends text line with text state parameters.
appendLine(TextFragment line, TextState textState, float lineSpacing)Appends text line with text state parameters
setMatrix(Matrix value)Sets Rotation of the paragraph.
setOldCodeCompatibilityMode(boolean value)Set old code compatibility mode
setBackgroundMode(int value)Set background mode for the text paragraph

TextParagraph()

public TextParagraph()

Creates TextParagraph object.

setBackgroundColor(Color value)

public void setBackgroundColor(Color value)

Sets background color for the text paragraph.

Parameters:

ParameterTypeDescription
valueColorColor object

getVerticalAlignment()

public VerticalAlignment getVerticalAlignment()

Gets vertical alignment for the text inside paragrph’s Rectangle .

Returns: VerticalAlignment - VerticalAlignment value

setVerticalAlignment(VerticalAlignment value)

public void setVerticalAlignment(VerticalAlignment value)

Sets vertical alignment for the text inside paragrph’s Rectangle .

VerticalAlignment.None is equal to VerticalAlignment.Bottom.

Parameters:

ParameterTypeDescription
valueVerticalAlignmentVerticalAlignment value

getSubsequentLinesIndent()

public float getSubsequentLinesIndent()

Gets subsequent lines indent value.

Returns: float - float value

setSubsequentLinesIndent(float value)

public void setSubsequentLinesIndent(float value)

Sets subsequent lines indent value.

Parameters:

ParameterTypeDescription
valuefloatfloat value

getFirstLineIndent()

public 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.

Returns: float - float value

setFirstLineIndent(float 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.

Parameters:

ParameterTypeDescription
valuefloatfloat value

isJustify()

public boolean isJustify()

Gets value whether text is justified.

Returns: boolean - boolean value

setJustify(boolean value)

public void setJustify(boolean value)

Sets value whether text is justified.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getHorizontalAlignment()

public HorizontalAlignment getHorizontalAlignment()

Gets horizontal alignment for the text inside paragrph’s Rectangle.

HorizontalAlignment.None is equal to HorizontalAlignment.Left.

Returns: HorizontalAlignment - HorizontalAlignment value

setHorizontalAlignment(HorizontalAlignment value)

public void setHorizontalAlignment(HorizontalAlignment value)

Sets horizontal alignment for the text inside paragrph’s Rectangle.

HorizontalAlignment.None is equal to HorizontalAlignment.Left.

Parameters:

ParameterTypeDescription
valueHorizontalAlignmentHorizontalAlignment value

getHyphenSymbol()

public String getHyphenSymbol()

Gets hyphen symbol that is used in hyphenation process.

The hyphenation symbol is “-” by default. To eliminate hyphen drawing (with wrapping procedure still in place) please set empty string string.Empty for HyphenSymbol.

Returns: java.lang.String - String value

setHyphenSymbol(String value)

public void setHyphenSymbol(String value)

Sets hyphen symbol that is used in hyphenation process.

The hyphenation symbol is “-” by default. To eliminate hyphen drawing (with wrapping procedure still in place) please set empty string string.Empty for HyphenSymbol.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString value

getFormattingOptions()

public TextFormattingOptions getFormattingOptions()

Gets formatting options.

Returns: TextFormattingOptions - TextFormattingOptions object

setFormattingOptions(TextFormattingOptions value)

public void setFormattingOptions(TextFormattingOptions value)

Sets formatting options.

Parameters:

ParameterTypeDescription
valueTextFormattingOptionsTextFormattingOptions object

getPosition()

public Position getPosition()

Gets position of the paragraph.

Returns: Position - Position value

setPosition(Position value)

public void setPosition(Position value)

Sets position of the paragraph.

Parameters:

ParameterTypeDescription
valuePositionPosition value

getTextRectangle()

public Rectangle getTextRectangle()

Gets rectangle of the text placed to the paragraph.

Returns: Rectangle - Rectangle object

getRectangle()

public Rectangle getRectangle()

Gets rectangle of the paragraph.

Returns: Rectangle - Rectangle object

setRectangle(Rectangle value)

public void setRectangle(Rectangle value)

Sets rectangle of the paragraph.

Parameters:

ParameterTypeDescription
valueRectangleRectangle object

getMargin()

public MarginInfo getMargin()

Gets the padding.

Returns: MarginInfo - MarginInfo value

setMargin(MarginInfo value)

public void setMargin(MarginInfo value)

Sets the padding.

Parameters:

ParameterTypeDescription
valueMarginInfoMarginInfo value

getRotation()

public double getRotation()

Gets or sets rotation angle in degrees.

Returns: double - double value

setRotation(double value)

public void setRotation(double value)

Gets or sets rotation angle in degrees.

Parameters:

ParameterTypeDescription
valuedoubledouble value

beginEdit()

public void beginEdit()

Begins the editing of the TextParagraph.

Improves performance of TextParagraph population. Any layout calculation is suspended until EndEdit method is invoked.

Note that method invoke can’t be nested.

endEdit()

public void endEdit()

Ends the editing of the TextParagraph.

Improves performance of TextParagraph population. Any layout calculation is suspended until EndEdit method is invoked.

Note that method invoke can’t be nested.

appendLine(String line)

public void appendLine(String line)

Appends text line

Parameters:

ParameterTypeDescription
linejava.lang.StringThe new line’s text.

appendLine(String line, float lineSpacing)

public void appendLine(String line, float lineSpacing)

Appends text line.

Parameters:

ParameterTypeDescription
linejava.lang.StringThe new line’s text.
lineSpacingfloatAdditional 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.

appendLine(String line, TextState textState)

public void appendLine(String line, TextState textState)

Appends text line with text state parameters.

Parameters:

ParameterTypeDescription
linejava.lang.StringThe new line’s text.
textStateTextStateText state of the new line.

appendLine(String line, TextState textState, float lineSpacing)

public void appendLine(String line, TextState textState, float lineSpacing)

Appends text line with text state parameters

Parameters:

ParameterTypeDescription
linejava.lang.StringThe new line’s text.
textStateTextStateText state of the new line.
lineSpacingfloatAdditional 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.

appendLine(TextFragment line)

public void appendLine(TextFragment line)

Appends text line with text state parameters.

Parameters:

ParameterTypeDescription
lineTextFragmentThe new line’s text.

appendLine(TextFragment line, TextState textState)

public void appendLine(TextFragment line, TextState textState)

Appends text line with text state parameters.

Parameters:

ParameterTypeDescription
lineTextFragmentThe new line’s text.
textStateTextStateText state of the new line.

appendLine(TextFragment line, TextState textState, float lineSpacing)

public void appendLine(TextFragment line, TextState textState, float lineSpacing)

Appends text line with text state parameters

Parameters:

ParameterTypeDescription
lineTextFragmentThe new line’s text.
textStateTextStateText state of the new line.
lineSpacingfloatAdditional 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.

setMatrix(Matrix value)

public void setMatrix(Matrix value)

Sets Rotation of the paragraph.

Parameters:

ParameterTypeDescription
valueMatrixMatrix object

setOldCodeCompatibilityMode(boolean value)

public void setOldCodeCompatibilityMode(boolean value)

Set old code compatibility mode

Parameters:

ParameterTypeDescription
valuebooleanboolean value

setBackgroundMode(int value)

public void setBackgroundMode(int value)

Set background mode for the text paragraph

Parameters:

ParameterTypeDescription
valueintint value