Op 9/12/2010 18:08, Esh schreef:
Here is my code:
private void generatepdfReport() {
PdfPTable  table = createPdfPTable(); // This will create my Table and add
PdfPCells to Table.
So createPdfPTable is supposed to return a PdfTable, but you say that this is the implementation:
private PdfPTable createPdfPTable() {
I don't see you constructing the table:
PdfPTable table = new PdfPTable(2);
table.addCell( new PdfPCell("Text111"));
table.addCell( new PdfPCell("Text22");
....... it goes like this...
}
In other words: you've sent me some code that could never work!
Unless the variable table is a class variable instantiated outside this method,
which would be very odd.

You also say you don't need a footer, yet your still setting footer rows:
                table .setSplitRows(false);
                table .setHeaderRows(2);
                table .setFooterRows(1);
pdfDocument.add(table);
}

Please don't treat the people on this list as pariahs!
In attachment, you find a simple code sample and the resulting PDF.
If only you'd read the documentation, you wouldn't have made me miss
my supper with my wife and kids!

Attachment: table.pdf
Description: Adobe PDF document

import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;


public class TableWithHeader {

        public static void main(String[] args) throws IOException, 
DocumentException {
                Document document = new Document();
                PdfWriter.getInstance(document, new 
FileOutputStream("table.pdf"));
                document.open();
                PdfPTable table = new PdfPTable(2);
                table.addCell("header 1");
                table.addCell("header 2");
                table.setHeaderRows(1);
                for (int i = 0; i < 100; i++) {
                        table.addCell("row " + i + " cell 1");
                        table.addCell("row " + i + " cell 2");
                }
                document.add(table);
                document.close();
        }
}
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to