com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class TextParagraph



  • 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);
     
    • Constructor Detail

      • TextParagraph

        public TextParagraph()

        Creates TextParagraph object.

    • Method Detail

      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Sets background color for the text paragraph.

        Parameters:
        value - Color object
      • getVerticalAlignment

        public int getVerticalAlignment()

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

        Returns:
        VerticalAlignment value
        See Also:

        VerticalAlignment.None is equal to VerticalAlignment.Bottom.

      • setVerticalAlignment

        public void setVerticalAlignment(int value)

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


        VerticalAlignment.None is equal to VerticalAlignment.Bottom.

        Parameters:
        value - VerticalAlignment value
        See Also:
        VerticalAlignment
      • getSubsequentLinesIndent

        public float getSubsequentLinesIndent()

        Gets subsequent lines indent value.

        Returns:
        float value
      • setSubsequentLinesIndent

        public void setSubsequentLinesIndent(float value)

        Sets subsequent lines indent value.

        Parameters:
        value - float value
      • isJustify

        public boolean isJustify()

        Gets value whether text is justified.

        Returns:
        boolean value
      • setJustify

        public void setJustify(boolean value)

        Sets value whether text is justified.

        Parameters:
        value - boolean value
      • getHorizontalAlignment

        public int getHorizontalAlignment()
        Gets horizontal alignment for the text inside paragrph's Rectangle.

        HorizontalAlignment.None is equal to HorizontalAlignment.Left.

        Returns:
        HorizontalAlignment value
        See Also:
        HorizontalAlignment
      • setHorizontalAlignment

        public void setHorizontalAlignment(int value)

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

        HorizontalAlignment.None is equal to HorizontalAlignment.Left.

        Parameters:
        value - HorizontalAlignment value
        See Also:
        HorizontalAlignment
      • getFormattingOptions

        public TextFormattingOptions getFormattingOptions()

        Gets formatting options.

        Returns:
        TextFormattingOptions object
      • setFormattingOptions

        public void setFormattingOptions(TextFormattingOptions value)

        Sets formatting options.

        Parameters:
        value - TextFormattingOptions object
      • getPosition

        public Position getPosition()

        Gets position of the paragraph.

        Returns:
        Position value
      • setPosition

        public void setPosition(Position value)

        Sets position of the paragraph.

        Parameters:
        value - Position value
      • getTextRectangle

        public Rectangle getTextRectangle()

        Gets rectangle of the text placed to the paragraph.

        Returns:
        Rectangle object
      • getRectangle

        public Rectangle getRectangle()

        Gets rectangle of the paragraph.

        Returns:
        Rectangle object
      • setRectangle

        public void setRectangle(Rectangle value)

        Sets rectangle of the paragraph.

        Parameters:
        value - Rectangle object
      • getMargin

        public MarginInfo getMargin()

        Gets the padding.

        Returns:
        MarginInfo value
      • setMargin

        public void setMargin(MarginInfo value)

        Sets the padding.

        Parameters:
        value - MarginInfo value
      • getRotation

        public double getRotation()

        Gets or sets rotation angle in degrees.

        Returns:
        double value
      • setRotation

        public void setRotation(double value)

        Gets or sets rotation angle in degrees.

        Parameters:
        value - double 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

        public void appendLine(String line)

        Appends text line

        Parameters:
        line - The new line's text.
      • appendLine

        public void appendLine(String line,
                               float lineSpacing)

        Appends text line.

        Parameters:
        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.
      • appendLine

        public void appendLine(String line,
                               TextState textState)

        Appends text line with text state parameters.

        Parameters:
        line - The new line's text.
        textState - Text state of the new line.
      • appendLine

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

        Appends text line with text state parameters

        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.
      • appendLine

        public void appendLine(TextFragment line)

        Appends text line with text state parameters.

        Parameters:
        line - The new line's text.
      • appendLine

        public void appendLine(TextFragment line,
                               TextState textState)

        Appends text line with text state parameters.

        Parameters:
        line - The new line's text.
        textState - Text state of the new line.
      • appendLine

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

        Appends text line with text state parameters

        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.
      • setMatrix

        public void setMatrix(Matrix value)

        Sets Rotation of the paragraph.

        Parameters:
        value - Matrix object
      • setOldCodeCompatibilityMode

        public void setOldCodeCompatibilityMode(boolean value)

        Set old code compatibility mode

        Parameters:
        value - boolean value
      • setBackgroundMode

        public void setBackgroundMode(int value)

        Set background mode for the text paragraph

        Parameters:
        value - int value
        See Also:
        TextParagraph.TextBackgroundMode