Title: Message

Greetings!!!
  I wanted to render a text into a rectangular boundary.
  Something like:


                 

I know the boundaries of the rectangle in terms of lowerXY and upperXY co-ordinates.

I tried using ColumnText, but the results I am getting are differnt. I thought of preparing a boundary of  (0,0) and (100,100) and embed the text inside.

But in the result, the text started from the top of the boundary.

I am attaching the code-snippet and the pdf file too.  I am looking for suggestions to correct the problem. My thought goes like i will get the intended result if vertical alignment can be set through ColumnText, which i couldn't find.

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import java.io.*;

public class Test
{
    public Test()
    {
        try
        {
            Document lDocument = new Document();
            lDocument.setPageSize(com.lowagie.text.PageSize.LETTER);
            PdfWriter lPdfWriter = PdfWriter.getInstance(lDocument
                                                         , new FileOutputStream(
                "Rectangle-Test.pdf"));
            lDocument.open();
            PdfContentByte lPdfContentByte = lPdfWriter.getDirectContent();
            lPdfContentByte.rectangle(0 , 0 , 100 , 100);
            lPdfContentByte.stroke();
            ColumnText lColumnText = new ColumnText(lPdfContentByte);
            Phrase lPhrase = new Phrase("A phrase of text A phrase of text");
            lColumnText.setSimpleColumn(lPhrase , 0 , 0 , 100 , 100 , 0 , Element.ALIGN_CENTER);
            lColumnText.go();

            lDocument.close();
        }
        catch(Exception lException)
        {
            lException.printStackTrace();
        }

    }
    public static void main(String[] args)
    {
        Test test1 = new Test();
    }

}

 



Regards
Ramana.JV.

****************************************************************************

This email may contain confidential
material. If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.

 ***************************************************************************

 

<<attachment: Outlook.bmp>>

Attachment: Rectangle-Test.pdf
Description: Binary data

Reply via email to