Well I determined that if you use setWidth(100), your table will consume 100 percent of the available width of the page. You can then use the setWidths(float[]) method to assign width percentages to each column based on this total width. This sort of works for me because my left column values are known in advance.
I also thought of using the FontMetrics class, but it would be so much easier if the cell object contained a method or field that simply provided this info. This API is totally new to me; I'm hoping I'm just missing the obvious... S |\_._/| .-. E | o o |_ / / S _.( T ) `./ / ---(((-`-(((--------- Scott Edward Skinner Systems Developer Regeneron Pharmaceuticals > From: [EMAIL PROTECTED] (Ryan Johnston) > Date: Fri, 02 Aug 2002 13:47:18 -0400 > To: [EMAIL PROTECTED] (Scott Edward Skinner), > [EMAIL PROTECTED] > Subject: RE: [iText-questions] Cell and Table Widths > > I am considering this very same problem in the near future in my application > as well. The solution I am thinking about right now is to use the FontMetrics > class to get the width and height of the string(s) and/or image(s) I place > into a cell and kepp a counter of the width used and width available for > additional cells so as not to overrun the space available on the page. > > If you need very wide tables, you might try using a large page size like A0, > but in my own tests I have found acrobat to be marginally successful in shrink > documents while keeping them legible. > > If you have a different idea, I'd like to hear it since I need to optimize my > dynamic PDF creation as much as possible for an eventual Servlet host for the > application. > > Scott Edward Skinner <[EMAIL PROTECTED]> wrote: > >> I'm creating a (simple) table that has two cells. The left cell is right >> justified; the right cell is left justified. I want the output (in >> fixed-width ASCII) to look something like this... >> >> Chocolate: good >> � Vanilla: better >> Strawberry: best >> >> So far so good. The problem is that I am used to HTML tables only using as >> much space as they need to accommodate the elements. The output I get from >> iText looks like this... >> >> Chocolate: � � � � � good >> � Vanilla: � � � � � better >> Strawberry: � � � � � best >> >> ...because of the arbitrary cell width sizes. Now I could set the width of >> the table but the problem is that the table will be dynamically generated >> and I do not know in advance what the data will be. I have tried to get the >> width of the cells so that I can add them together and set the table width, >> but the methods always return "0.0" or null. >> >> Any ideas? >> >> S � � |\_._/| � � .-. >> E � � | o o |_ � / / >> S � _.( �T �) `./ / >> ---(((-`-(((--------- >> >> Scott Edward Skinner >> Systems Developer >> Regeneron Pharmaceuticals >> >> >> >> >> ------------------------------------------------------- >> This sf.net email is sponsored by:ThinkGeek >> Welcome to geek heaven. >> http://thinkgeek.com/sf >> _______________________________________________ >> iText-questions mailing list >> [EMAIL PROTECTED] >> https://lists.sourceforge.net/lists/listinfo/itext-questions >> > > > __________________________________________________________________ > Your favorite stores, helpful shopping tools and great gift ideas. Experience > the convenience of buying online with Shop@Netscape! > http://shopnow.netscape.com/ > > Get your own FREE, personal Netscape Mail account today at > http://webmail.netscape.com/ > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
