Hello all,

this is my very first post to the list and I'd really appreciate any
help or pointers for the following problem:

I try to create invoices using iText in a JBoss environment. The
document I create consists of a ColumnText object containing a PdfPTable
set to 100% and containing 4 columns set to 10%, 70%, 10% and 10%.

Though I explicitly set word wrap to true when adding cells, the content
of the second column is never wrapped at all resulting in very ugly
rows if the text is too long to fit the cell.

If I remove the width percentage and simply add cells to the table as
they come the text is wrapped.

These are some excerpts from the code:

Creating ColumnText:
       ColumnText ct = new ColumnText( cb );

       ct.setSimpleColumn(
         mm2pt( LEFT_MARGIN_KTIT ),
         mm2pt( BOTTOM_MARGIN_KTIT ),
         PageSize.A4.getWidth() - mm2pt( RIGHT_MARGIN_KTIT ),
         PageSize.A4.getHeight() - mm2pt( FIRST_PAGE_TOP_MARGIN_KTIT ),
         10,
         Element.ALIGN_LEFT
       );

Creating table:
       PdfPTable table = new PdfPTable( 4 );
       table.setWidthPercentage( 100 );
       table.setWidths( new float[] { 0.1f, 0.6f, 0.15f, 0.15f } );
       table.setHeaderRows( 1 );

Adding cells:
       Chunk c = new Chunk( value, font );
       c.setHyphenation( hyphenation );
       cell.setNoWrap( false );
       cell.setPhrase( new Phrase( c ) );
       table.addCell( cell );

Fitting text on following pages:
       int status = ColumnText.START_COLUMN;
       while( ColumnText.hasMoreText( status ) ) {
         doc.newPage();
         doc.setMargins( 0, 0, 0, 0 );

         ct.setSimpleColumn(
           mm2pt( LEFT_MARGIN_KTIT ),
           mm2pt( BOTTOM_MARGIN_KTIT ),
           PageSize.A4.getWidth() - mm2pt( FF_PAGE_RIGHT_MARGIN_KTIT ),
           PageSize.A4.getHeight() - mm2pt( FF_PAGE_TOP_MARGIN_KTIT ) - mm2pt( 
BOTTOM_MARGIN_KTIT ),
           10,
           Element.ALIGN_LEFT
         );

         status = ct.go();
       }


Any ideas? Am I missing out something?


-- 
________________________________________________________________________

  Dipl.-Inform. Marc-Christian Schröer       mailto:[EMAIL PROTECTED]
  Geschäftsführer / CEO
  ----------------------------------------------------------------------
  Klute-Thiemann
  Informationstechnologie GmbH & Co. KG           Tel. +49.231.9742.6600
  Emil-Figge-Strasse 76-80                        Fax. +49.231.9742.6601
  D-44227 Dortmund                          http://www.klute-thiemann.de

  Registergericht: Amtsgericht Dortmund, HRA 13 914
  Gesellschafter : Thomas Klute, Marc-Christian Schröer
________________________________________________________________________

Diese Nachricht ist vertraulich.  Sie ist ausschliesslich  fuer  den im
Adressfeld  ausgewiesenen  Adressaten bestimmt.  Sollten Sie  nicht der
vorgesehene  Empfaenger  sein,  so bitten wir  um eine kurze Nachricht.
Jede   unbefugte   Weiterleitung   oder  Fertigung   einer  Kopie   ist
unzulaessig. Wenn Sie diese Nachricht fälschlicherweise  erhalten haben
informieren Sie uns bitte unverzüglich  indem Sie die Originalnachricht
an den Absender zurücksenden.

The   information  contained  in   this  e-mail  is  intended  for  the
named recipient(s)  only.  It may contain  privileged and  confidential
information, and if you are not the addressee or the person responsible
for delivering this  to  the  addressee, you  may  not copy, distribute
or take action in reliance on it. If you  have received  this e-mail in
error, please  notify us immediately by  returning the original message
to the sender by e-mail.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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
  • ... Marc-Christian Schröer - Klute-Thiemann Informationstechnologie GmbH & Co. KG
    • ... Marc-Christian Schröer - Klute-Thiemann Informationstechnologie GmbH & Co. KG

Reply via email to