I was wondering if I could get some help on this. Several hours of googling have not turned up any promising results. Anyone have any ideas? Is this not possible in itext?
On Tue, Dec 8, 2009 at 3:22 PM, Talmage <[email protected]> wrote: > How do I make it so nested tables do not expand to the height of the > cell they are contained in, but instead use the height of their > contents? > > In the below code the cell with the background color of red and the > text "One" in it is expanded so the red fills the same height as the > two tables with two rows in it. I want it so the Red table is only the > height needed to print "One" -- that is I want the one row high table > to stay one row tall. > > Hope that makes sense, I have included the java code showing the > behavior I don't want and a small HTML snippet that produces the > result layout wise that I want (tested on IE7, FF3.5). For the sake of > simplicity I did not turn off borders as I am not worried about > borders/padding in this question. > > > Document document = new Document(PageSize.LETTER.rotate()); > > try > { > PdfWriter.getInstance(document, new FileOutputStream("C:\\test.pdf")); > > document.open(); > > PdfPTable outerTable = new PdfPTable(3); > outerTable.setTotalWidth(600); > outerTable.setWidths(new float[] {200,200,200}); > outerTable.setLockedWidth(true); > > PdfPTable twoRowsTallTable = new PdfPTable(1); > twoRowsTallTable.addCell("Row1"); > twoRowsTallTable.addCell("Row2"); > > > PdfPTable oneRowstallTable = new PdfPTable(1); > PdfPCell cellWithColor = new PdfPCell(new Phrase("One")); > cellWithColor.setBackgroundColor(Color.RED); > oneRowstallTable.addCell(cellWithColor); > > > outerTable.addCell(oneRowstallTable); > outerTable.addCell(twoRowsTallTable); > outerTable.addCell(twoRowsTallTable); > > document.add(outerTable); > > document.close(); > > } > catch (Exception e) > { > e.printStackTrace(); > } > > > > HTML Of What I want: > <table width="100%"> > <tr> > <td width="33%" valign="top"> > <table width="100%"> > <tr> > <td bgcolor="#FF0000">One</td> > </tr> > </table> > </td> > <td> > <table width="100%"> > <tr> > <td>Row1</td> > </tr> > <tr> > <td>Row2</td> > </tr> > </table> > </td> > <td> > <table width="100%"> > <tr> > <td>Row1</td> > </tr> > <tr> > <td>Row2</td> > </tr> > </table> > </td> > </tr> > </table> > ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-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/
