I have a PdfPTable which contains nested PdfPTables.  I'd like to be able to
determine the optimal width of the columns for the outer table by running an
algorithm against the widths of the tables that the rows will contain.  I
have already confirmed that I can build my sub-tables before I render the
outer table.  Is there a way to determine the width of the sub tables before
I actually put them into the document?

Here is what I tried:
// Calculate relative widths of each table.  We'll use this then to
// determine the widths of the rows of the outer table.
float width1 = statsTable1.getTotalWidth() ;
float width2 = statsTable2.getTotalWidth();
float width3 = statsInfoTable.getTotalWidth() ;
float width4 = specInfoTable.getTotalWidth() ;
float totalWidth = width1 + width2 + width3 + width4 ;

float colWidths[] = new float[4] ;
colWidths[0] = width1 / totalWidth ;
colWidths[1] = width2 / totalWidth ;
colWidths[2] = width3 / totalWidth ;
colWidths[3] = width4 / totalWidth ;

// Outer Table
PdfPTable outerTable = new PdfPTable ( colWidths ) ;
outerTable.setWidthPercentage(100f);

Note - the four tables used to make up the cells allow the document to
determine their optimal widths; I do not set them in advance.

When I run the above code, I get a size of 0 for each of the tables (which
will ultimately lead to a divide by 0 error).  Is this the proper way to
determine the sizing?  If not, what is it?

Any help is appreciated.

Bill



-------------------------------------------------------
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

Reply via email to