There's no solution for that problem. Table text and the generic text placed with 
Document.add() uses the operator Td that is incremental. As the numbers greater than 1 
are place in the PDF with 2 decimal digits small discrepancies may arise. PdfPTable 
always places the text at absolute positions and does not have this rounding problems.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Carmona Perez, David
> Sent: Tuesday, May 18, 2004 9:49 AM
> To: Itext-Questions (E-mail)
> Subject: RV: [iText-questions] Background misaligned in tables
> 
> 
> Hi all,
> 
> Finally I have found the cause of the problem, it is due to 
> rounding errors.
> Text transforms are done incrementally for each row, so even 
> a small error is accumulated.
> I always work in millimeters and do the conversion to points. 
>  Here is some small sample code that shows this problem:
> 
> import java.io.FileOutputStream;
> import java.awt.Color;
> 
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.PdfWriter;
> 
> public class Pru {
>       // Conversion factor to millimeters
>       static final float mm = 72/25.4f;
>       public static void main(String[] args) {
>               Document document = new Document();
>               try {
>                       PdfWriter.getInstance(document, new 
> FileOutputStream("a.pdf"));
>                       document.open();
>                       // step 4: we create a table and add it 
> to the document
>                       Table tbl = new Table(3);
>                       for (int row = 0; row < 50; row++) {
>                               for (int col = 0; col < 3; col++) {
>                                       Cell cell = new Cell();
>                                       cell.add(new 
> Chunk(""+row+"."+col, new Font(Font.HELVETICA, 8)));
>                                       cell.setLeading(16-2.1f*mm);
>                                       
> cell.setVerticalAlignment(Element.ALIGN_TOP);
>                                       
> cell.setBackgroundColor(row % 2 == 0 ? Color.yellow:Color.white);
>                                       tbl.addCell(cell);
>                               }
>                       }
>                       document.add(tbl);
>                       System.out.println("Output file created 
> successfully");                     
> 
>               } catch(Exception e) {
>                       e.printStackTrace();
>               }
>               document.close();
>       }
> }
> 
> I attach the output PDF file.
> The problem disappers if I do this:
>       cell.setLeading((int)(16-2.1f*mm));
> 
> Any solution to this problem?
> 
> -----Mensaje original-----
> De: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] nombre 
> de Carmona Perez, David
> Enviado el: viernes, 14 de mayo de 2004 14:21
> Para: Itext-Questions (E-mail)
> CC: Bartolome Pascual, Ismael
> Asunto: [iText-questions] Background misaligned in tables
> 
> 
> Hi,
> 
> My problem is:
> 
> I�m creating a table with Table / PdfTable in PDF.  Every 
> line has a different background color. 
> 
> For each cell, I use the same font and it takes exactly one line.
> Lines are output equally spaced and look ok, but the 
> background is missaligned and as we go downwards the page, 
> the background is progressivaly more above that the 
> corresponding line of text.
> 
> Does anyone know the cause?
> Has this happened to anybody else?
> 
> Any help will be greatly appreciated.
> 
> David
> *************************************************************
> Este correo ha sido procesado por el antivirus del Grupo FCC.
> *************************************************************
> 
> 
> *************************************************************
> Este correo ha sido procesado por el Antivirus del Grupo FCC.
> *************************************************************
> 
> 
> *************************************************************
> Este correo ha sido procesado por el Antivirus del Grupo FCC
> *************************************************************
> 


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to