You must use BaseFont.getWidthPoint() to get the width of the text and then
add the right and left padding plus some slack.

Best Regards,
Paulo Soares

----- Original Message -----
From: "Margarita L�pez del Campo" <[EMAIL PROTECTED]>
To: "iText" <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 9:39
Subject: [iText-questions] Problem with PdfPTable


Hello!

  I have to generate a Pdf document from a web application. One of the
functions
I have to create a PdfPTable to put like header of another table is:

    public PdfPTable pintarCabecera1(String texto, Font tipoLetra)
throws
DocumentException{

    PdfPTable logoTabla = new PdfPTable(1);
    PdfPCell logoC = new PdfPCell(new Phrase(texto,
tipoLetra));

logoC.setBorder(Rectangle.TOP|Rectangle.BOTTOM|Rectangle.LEFT|Rectangle.
RIGHT);
    logoC.setBorderWidth(1f);
    logoC.setBorderColor(new Color(254, 210, 109));
    logoC.setBackgroundColor(new Color(254, 210, 109));
    logoC.setPadding(1f);
    logoC.setPaddingRight(0f);
    logoC.setPaddingLeft(10f);


logoTabla.setTotalWidth(texto.length()*(tipoLetra.size()-(float)(3.5)));
    logoTabla.addCell(logoC);
    return logoTabla;

    }

and I use this like I put below:

logoTabla = pintarCabecera1("SERVICIOS
CONTRATADOS", tipoLetraCabecera);
logoTabla.writeSelectedRows(0, -1,
comienzoCabeceras, topDocumento,
writer.getDirectContent());

my problem is that when I write "SERVICIOS CONTRATADOS" the result is
put
in the Pdf document in two lines but if I write some longer text like
"DATOS
DE PERSONALIZACI�N DE FACTURA Y SERVICIOS" the result is written in one
single line which is I need.

Coudl someone help me????  I need to write "SERVICIOS CONTRATADOS" in
one
single line and I don`t understand where is the problem.

Thank you.

Margarita Lopez.

���OFERTA VERANO: TISCALI ADSL TOP 24 h. a 9,95 EUR/mes
m�s m�sica y webcam GRATIS!!!

http://acceso.tiscali.es/html/mxtop.html?did=adt-7390015








-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click
here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to