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!!
|
|
0
|
|
|
|
Reply
|
javacc1 (26)
|
9/25/2006 10:39:17 PM |
|
Hi,
John wrote:
> 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
|
|
0
|
|
|
|
Reply
|
Ingo
|
9/26/2006 8:37:33 AM
|
|
|
1 Replies
1268 Views
(page loaded in 0.042 seconds)
|