Sverre Moe wrote:
> I have just taken use of iText and come across a problem with my table. 
> Column one in the table is a fixed string size which I know,

So if you use getWidthPoint you know the width of the String in pt
(let's call it fixedWidth).

> but column two has a variable string size according to user input.

OK, if you have all the Strings from the user input, try
BaseFont.getWidthPoint(String text, float fontSize)
or put the String in a Chunk and do chunk.getWidthPoint().
Let's call this value userdefinedWidth.

> What I need is to automatically adjust the second columns width 
> according to the string size.

Now that you have the width in pt of the content, you're
going to add to the table, you can define the absolute
width of each column like this:

float[] widths =
   { fixedWidth + padding, userdefinedWidth + padding};
table.setTotalWidth(widths);
table.setLockedWidth(true);

> How could I set the setWidthPercentage and cellwidth according to the 
> string size?

As explained in Chapter 6 of my book, a table stores
two widths: one expressed as a percentage (used by default)
and an absolute width. By setting 'locked width' to true,
you indicate that you want the table to ignore the width
percentage and use the absolute width instead.
HTH,
Bruno

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to