com.cete.dynamicpdf.pageelements
Class TextArea




Examples Description
Example 1 The following example will display text on the page.
Example 2 The following example shows you how to use the GetOverflowTextArea object to allow text of variable length to flow onto new pages as needed.
Example 3 The following example shows you how to use the GetOverflowTextArea object With x,y Coordinates to allow text of variable length to flow onto new pages as needed.
Example 4 The following example shows you how to use the GetOverflowTextArea object With x,y Coordinates ,Width ,and height to allow text of variable length to flow onto new pages as needed.



Example 1: The following example will display text on the page.

Example.

The following example will display text on the page.

import com.cete.dynamicpdf.*;
 import com.cete.dynamicpdf.pageelements.*;
 
 public class MyClass{
       public static void main(String args[]){
 
           // Create a PDF Document
           Document document = new Document();
 
           // Create a Page and add it to the document
           Page page = new Page();
           document.getPages().add(page);
 
           // Create a text area
           TextArea textArea = new TextArea("This is the underlined " +
           "text of a TextArea", 100, 100, 400, 30, 
           com.cete.dynamicpdf.Font.getHelveticaBoldOblique(), 18 );
 
           // Change the underline property to true
           textArea.setUnderline(true);
 
           // Add the text area to the page
           page.getElements().add(textArea); 
 
           // Save the PDF
           document.draw("[Physicalpath]/MyDocument.pdf");
       }
 }

Top

Example 2: The following example shows you how to use the GetOverflowTextArea object to allow text of variable length to flow onto new pages as needed.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;

public class MyClass
{
    public static void Main(String args[])
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a string and assign it to text of variable length
        String myVariableText = "";
        for( int i = 0; i < 50; i++ )
            myVariableText += "This is a sentence that I will use as my variable length text.  ";

        // Create a text area
        TextArea textArea = new TextArea( myVariableText, 0, 0, 250, 200 ); 
    
        do
        {
            // Create a new page
            Page page = new Page();

            // Add the text area to the page;
            page.getElements().add( textArea );

            // Add the page to the document
            document.getPages().add( page );

            // Set the text area object equal to the rest of the text that did not fit
            // if all the text did fit, GetOverflowTextArea will return null
            textArea = textArea.getOverflowTextArea();
        } while( textArea != null );
    
        // Save the PDF
        document.draw("[Physicalpath]/MyDocument.pdf" );
    }
}

Top

Example 3: The following example shows you how to use the GetOverflowTextArea object With x,y Coordinates to allow text of variable length to flow onto new pages as needed.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;

public class MyClass
{
    public static void Main(String args[])
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a string and assign it to text of variable length
        String myVariableText = "";
        for( int i = 0; i < 50; i++ )
            myVariableText += "This is a sentence that I will use as my variable length text.  ";

        // Create a text area
        TextArea textArea = new TextArea( myVariableText, 0, 0, 250, 200 ); 
    
        do
        {
            // Create a new page
            Page page = new Page();

            // Add the text area to the page;
            page.getElements().add( textArea );

            // Add the page to the document
            document.getPages().add( page );

            // Set the text area object equal to the rest of the text that did not fit
            // if all the text did fit, GetOverflowTextArea will return null
            textArea = textArea.getOverflowTextArea(100,20);
        } while( textArea != null );
    
        // Save the PDF
        document.draw("[Physicalpath]/MyDocument.pdf" );
    }
}

Top

Example 4: The following example shows you how to use the GetOverflowTextArea object With x,y Coordinates ,Width ,and height to allow text of variable length to flow onto new pages as needed.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;

public class MyClass
{
    public static void Main(String args[])
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a string and assign it to text of variable length
        String myVariableText = "";
        for( int i = 0; i < 50; i++ )
            myVariableText += "This is a sentence that I will use as my variable length text.  ";

        // Create a text area
        TextArea textArea = new TextArea( myVariableText, 0, 0, 250, 200 ); 
    
        do
        {
            // Create a new page
            Page page = new Page();

            // Add the text area to the page;
            page.getElements().add( textArea );

            // Add the page to the document
            document.getPages().add( page );

            // Set the text area object equal to the rest of the text that did not fit
            // if all the text did fit, GetOverflowTextArea will return null
            textArea = textArea.getOverflowTextArea(100,20,200,200);
        } while( textArea != null );
    
        // Save the PDF
        document.draw("[Physicalpath]/MyDocument.pdf" );
    }
}

Top