Can somebody please point out what I'm doing wrong.

I've setup a table with two columns, but I'm having trouble getting content
to span both columns.

I add a header across two columns with centered text which works fine, but
when I add left justified content the copy only occupies the first column,
but the strange thing is that the colored background is across both columns.

I've attached the relevant code below:

            PdfPTable table = new PdfPTable(2);
            table.setWidthPercentage(100);

            // this renders fine
            PdfPCell cell = new PdfPCell(new Phrase("Sample Header Across
two columns", boldText));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(PxsConstants.BASIS32_LIGHT_GREEN);
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPadding(2);
            cell.setPaddingTop(4);
            cell.setColspan(2);
            cell.setBorderWidthTop(2f);
            cell.setBorderColorTop(Color.BLACK);
            table.addCell(cell);

        // the text in these cells only renders in the first column, but the
background color is across both
            for(ResponseData result: dataList){
                if(new Integer(0).equals(result.getIntegerData())){
                    cell = new PdfPCell(new
Phrase(result.getQuestion().getLocalisedDetails(), regularText));
                    cell.setColspan(2);
                    cell.setBackgroundColor(cellBack);
                    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                    cell.setBorder(Rectangle.NO_BORDER);
                    cell.setPaddingLeft(35);
                    table.addCell(cell);
                }
            }

-- 
View this message in context: 
http://www.nabble.com/PdfPCell-Content-no-filling-entire-colspan-tp25189334p25189334.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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