You must call setTotalWidth() before writing the rows. The table can't guess
the size.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Jpenuela [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, February 13, 2003 10:57
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] writeSelectedRows
> 
> I get the error "java.lang.RuntimeException: The table width must be
> greater than zero." when I call  PdfPTable method writeSelectedRows(0, -1,
> 0,740, cb) but it works fine when I call Document .add(element) with the
> same PdfPTable.
>  
> Any idea?
>  
> Here is the code (cb is PdfContentByte initialized in the onOpenDocument
> method):
>  
>  public void onStartPage(PdfWriter writer, Document document)
>   {int amplada[] = {100}; 
>     try
>     {  cb.beginText();
>       cb.setTextMatrix(196,805);
>       BaseFont bf =
> BaseFont.createFont(BaseFont.TIMES_ROMAN,BaseFont.CP1252,BaseFont.NOT_EMBE
> DDED);      
>       cb.setFontAndSize(bf,8);
>       cb.showText("ESTUDIANTS D'ESTADA TEMPORAL UB - MODALITAT
> INTERCANVI");
>       cb.endText();
>  
>        PdfPTable t = new PdfPTable(1);
>        t.setWidths(amplada);
>        t.setWidthPercentage(100);        
>        t.addCell(new Phrase("CURS ACADEMIC"));
>        document.add(t);   // IT WORKS FINE
>        t.writeSelectedRows(0, -1, 0,740, cb);  // IT give the exception
>       
>     }
>     catch (Exception e)
>     {e.printStackTrace();}     
>   }
> 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to