Hi pbs,

2010/1/6 pbs <[email protected]>

>
> Hi.
>
> I am trying to se the first column in a table to a different width. The
> table can have a different number of columns each time the program is run,
> for example it may have 5 columns one time, then depending on the date it
> is
> presenting it may have 7.
>
> This works fine using by passing the number of columns while creating the
> table object as follows :
> PdfPTable table = new PdfPTable(intColumns);
>
> All columns are of the same width. However, I would like the first column
> to
> be narrower. If I always knew the number of columns I could use this
> PdfPTable table = new PdfPTable (new float [] { 1.0f, 2.0f, 2.0f, 2.0f,
> 2.0f
> });
>
> Is there a way around this?
>

Have you tried simple math?

- Create an array which size is the number of columns (i.e. your variable
intColumns).
- The first value will be the fixed width of the first column.
- The other values can be calculated quite easily:
    (totalWidth - firstColumnWidth) / (intColumns - 1)
- Use the array in the PdfPTable constructor.

If you want the width of the first column to be a fraction of the others, it
involves a little bit more calculus, but nothing you can't cope with, I'm
sure. :)

HTH,
alexis
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to