Thanks, that solved it.

I am still trying to understand why this works the way it does though.
I re-read the section in the iText book on text mode versus composite
mode (pages 207-211) and still think I am lost. But here is how I am
currently grasping this:

In my original method when the tables are added directly the cell
becomes those tables, and therefore stretches to the width/height of
the overall table. In composite mode the cell contains the table,
rather than "being" the table. Is this correct? Or am I totally wrong
about how this is working?

On Wed, Dec 9, 2009 at 2:29 PM, 1T3XT info <[email protected]> wrote:
> Talmage wrote:
>> 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?
>
> Well, it's 23:25 now, and I've been working since 8:30 this morning.
> That's a very long working day.
>
> And yet I find the time to answer a question with a very obvious answer:
> add the table in composite mode!
>
> Document document = new Document(PageSize.LETTER.rotate());
> try {
>   PdfWriter.getInstance(document, new FileOutputStream("nested.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);
>   oneRowstallTable.setWidthPercentage(100);
>   PdfPCell cellWithColor = new PdfPCell(new Phrase("One"));
>   cellWithColor.setBackgroundColor(BaseColor.RED);
>   oneRowstallTable.addCell(cellWithColor);
>   PdfPCell cell = new PdfPCell();
>   cell.addElement(oneRowstallTable);
>   outerTable.addCell(cell);
>   outerTable.addCell(twoRowsTallTable);
>   outerTable.addCell(twoRowsTallTable);
>   document.add(outerTable);
>   document.close();
> }
> catch (Exception e) {
>   e.printStackTrace();
> }
>
> Sorry for yawning, but I'm really tired.
> --
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
>
> ------------------------------------------------------------------------------
> 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/
>

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

Reply via email to