Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

reach max. number of columns in PdfPTable in iText?

Thread view: 
John - 25 Sep 2006 23:39 GMT
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!!
Ingo R. Homann - 26 Sep 2006 09:37 GMT
Hi,

> I want to create a PDF table in Landscape with 16 columns using Java
> iText API.
[quoted text clipped - 28 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.