Works correctly. If you have colspan 2 the nested table inside will occupy
the two columns space instead of one. What result would you expect?

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Khaled Alakhras [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, November 06, 2002 21:37
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] Setting the colSpan on a PdfPCell that
> contains a PdfPTable
> 
> It seems that there is a problem when setting the colSpan of a PdfPCell
> that contains a PdfPTable.  Setting the colSpan effects all other cells
> that contain a PdfPTable also.  Please see attahced example.
> 
> Thanks,
> Khaled
> 
> Test.java
> 
> import com.lowagie.text.Document;
> 
> import com.lowagie.text.PageSize;
> 
> import com.lowagie.text.Phrase;
> 
> import com.lowagie.text.pdf.PdfPCell;
> 
> import com.lowagie.text.pdf.PdfPTable;
> 
> import com.lowagie.text.pdf.PdfWriter;
> 
> import java.awt.Color;
> 
> import java.io.FileOutputStream;
> 
>  
> 
> public class Test
> 
> {
> 
> public static void main(String[] args)
> 
> {
> 
> Document document = new Document(PageSize.A4, 50, 50, 50, 50);
> 
> try
> 
> {
> 
> PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream("test.pdf"));
> 
> document.open();
> 
> PdfPCell cell;
> 
> PdfPTable table = new PdfPTable(2);
> 
> table.setWidthPercentage(70);
> 
> table.setHeaderRows(0);
> 
> cell = table.getDefaultCell();
> 
> cell.setBorderWidth(1);
> 
> cell.setBorderColor(Color.blue);
> 
> // Create a 2X2 sub-table
> 
> PdfPTable nested = new PdfPTable(2);
> 
> for (int k = 0; k < 4; ++k)
> 
> {
> 
> cell = new PdfPCell(new Phrase("nested.Cell " + k));
> 
> cell.setBorderWidth(1);
> 
> cell.setBorderColor(Color.blue);
> 
> cell.setBackgroundColor(Color.red);
> 
> nested.addCell(cell);
> 
> }
> 
> cell = new PdfPCell(new Phrase("Table.Cell0"));
> 
> cell.setBorderWidth(1);
> 
> cell.setBackgroundColor(Color.blue);
> 
> table.addCell(cell);
> 
> cell = new PdfPCell(new Phrase("Table.Cell1"));
> 
> cell.setBorderWidth(1);
> 
> cell.setBackgroundColor(Color.blue);
> 
> table.addCell(cell);
> 
> cell = new PdfPCell(new Phrase("Table.Cell2"));
> 
> cell.setBorderWidth(1);
> 
> cell.setBackgroundColor(Color.blue);
> 
> table.addCell(cell);
> 
> cell = new PdfPCell(nested);
> 
> cell.setBorderWidth(1);
> 
> cell.setColspan(1);
> 
> cell.setPadding(1);
> 
> table.addCell(cell);
> 
> cell = new PdfPCell(nested);
> 
> cell.setBorderWidth(1);
> 
> cell.setColspan(2); //** NOTE: setting the colspan for this cell effects
> all other cells that
> 
> //** contain a table.
> 
> cell.setPadding(1);
> 
> cell.setBackgroundColor(Color.blue);
> 
> table.addCell(cell);
> 
> document.add(table);
> 
> document.close();
> 
> }
> 
> catch (Exception de)
> 
> {
> 
> de.printStackTrace();
> 
> }
> 
> }
> 
> }
> 
> 
> 
>   _____  
> 
> Do you Yahoo!?
> HotJobs <http://rd.yahoo.com/careers/mailsig/*http://www.hotjobs.com> -
> Search new jobs daily now


-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to