Well... I haven't get any answer for 5 days. Maybe you are just lazy like me
and it's too hard to compile code which I posted. So I will try to explain :
I have a table with cells which have rowSpan more than 1:
_________________________________
| | |__________|
| | | |
|__________ |__________ |__________|
|__________ |__________ |__________|
|__________ |__________ |__________|
|__________ |__________ |__________|
But when I invoke method setHeaderRows(3) I get the following table:
_________________________________
|__________ |__________ |__________|
| | | |
|__________ |__________ |__________|
|__________ |__________ |__________|
|__________ |__________ |__________|
|__________ |__________ |__________|
netslow wrote:
>
> Hi. I have some problems with table when I invoke setHeaderRows(X) if it
> has few cells with rowSpan greater than 1.
>
> Here is example code. As you can see result pdf document has
> broken(rowSpan = 1 instead 3) cells in header:
>
> public class TableIssue
> {
>
> private static Font fontCell = null;
> private static BaseFont baseFont = null;
>
> static {
> try
> {
> baseFont =
> BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI,BaseFont.NOT_EMBEDDED);
> fontCell = new Font(baseFont, 8);
>
> } catch (DocumentException e)
> {
> e.printStackTrace();
> } catch (IOException e)
> {
> e.printStackTrace();
> }
> }
>
> private static PdfPCell createCell(String text,int rowSpan,int colSpan){
>
> PdfPCell cell = new PdfPCell(new Phrase(text,fontCell));
> if(rowSpan>1){
> cell.setRowspan(rowSpan);
> }
> if(colSpan>1){
> cell.setColspan(colSpan);
> }
> cell.setHorizontalAlignment(Element.ALIGN_CENTER);
> cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
> return cell;
> }
>
> public static void main(String args[]) {
> try {
> Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
> PdfWriter.getInstance(doc, new
> FileOutputStream("C:\\TEMP\\tableIssue.pdf"));
> doc.open();
>
> int colNum = 5;
>
> int rowNum = 150;
> int tableCount = 5;
> for(int k=0;k<tableCount;k++){
> PdfPTable table = new PdfPTable(colNum);
> int[] widths = new int[]{10,10,10,10,10};
> table.setWidths(widths);
> table.setWidthPercentage(100);
> table.getDefaultCell().setPadding(2);
> table.getDefaultCell().setBorderWidth(1);
>
> table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
> table.addCell(createCell("rowspan 3 ",3,1));
> table.addCell(createCell("rowspan 3
> ",3,1));
> table.addCell(createCell("rowspan 3
> ",3,1));
> table.addCell(createCell("rowspan 1
> ",1,1));
> table.addCell(createCell("rowspan 1
> ",1,1));
> table.addCell(createCell("rowspan 1
> ",1,1));
> table.addCell(createCell("rowspan 1
> ",1,1));
> table.setHeaderRows(3);
> for(int j=0;j<rowNum;j++){
>
> table.addCell(createCell("rowspan 1 ",1,1));
>
> table.addCell(createCell("rowspan 1 ",1,1));
>
> table.addCell(createCell("rowspan 1 ",1,1));
>
> table.addCell(createCell("rowspan 1 ",1,1));
>
> table.addCell(createCell("rowspan 1 ",1,1));
> }
> doc.add(table);
> doc.newPage();
> }
> doc.close();
> }
> catch ( Exception e ) {
> e.printStackTrace();
> }
> }
> }
>
> How can I fix it? Maybe I did not properly use the tables? Could someone
> help me?
>
>
--
View this message in context:
http://www.nabble.com/setHeaderRows-and-setRowSpan-tp24494391p24566984.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
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/