reach max. number of columns in PdfPTable in iText?

J

John

I want to create a PDF table in Landscape with 16 columns using Java
iText API.

I use class PdfPTable, but it looks like the maximum number of columns
is 12. If I set the
number of columns go beyond 12, then I get ExceptionConverter:
java.io.IOException: The document has no pages.

Is that true?

Here's my code fragment:

Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
int NumColumns = 13;
try {
PdfPTable datatable = new PdfPTable(NumColumns);
datatable.getDefaultCell().setPadding(3);
int headerwidths[] = {9, 4, 8, 10, 8, 11, 9, 7, 9, 10, 4, 5, 5}; //
percentage
datatable.setWidths(headerwidths);
datatable.setWidthPercentage(100); // percentage
for (int x = 0; x < NumColumns; x++) {
datatable.addCell("hello");
}
document.add(datatable);
}
catch(Exception e) {
e.printStackTrace();
}


Any ideas? Or better approach to my problem? Maybe this is the
limitations of iText API??

Please advice. thanks!!
 
I

Ingo R. Homann

Hi,
I want to create a PDF table in Landscape with 16 columns using Java
iText API.

I use class PdfPTable, but it looks like the maximum number of columns
is 12. If I set the
number of columns go beyond 12, then I get ExceptionConverter:
java.io.IOException: The document has no pages.

Is that true?

Here's my code fragment:

Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
int NumColumns = 13;
try {
PdfPTable datatable = new PdfPTable(NumColumns);
datatable.getDefaultCell().setPadding(3);
int headerwidths[] = {9, 4, 8, 10, 8, 11, 9, 7, 9, 10, 4, 5, 5}; //
percentage
datatable.setWidths(headerwidths);
datatable.setWidthPercentage(100); // percentage
for (int x = 0; x < NumColumns; x++) {
datatable.addCell("hello");
}
document.add(datatable);
}
catch(Exception e) {
e.printStackTrace();
}


Any ideas? Or better approach to my problem? Maybe this is the
limitations of iText API??

Your problem is that your headerwidths-Array has more elements than the
datatable. iText does not display Table-Rows that are not "complete".
Therefore, the table is empty, and therefore, the page is empty. And
iText does not like empty documents.

Ciao,
Ingo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top