Thanks for the info.
 
So you would always recommend writing a PdfPTable using writeSelectedRow, and not 
adding it to the document?
 
I found out that I could get the required effect by setting the widthPercentage on the 
table. It seems to us here, that what is going on, is that the meassurement of a 
rowheight is correct, when widths set, and totalWidth of the table is set, but when 
adding the table to the page the totalWidth is not honored, for that you need to 
calculate the totalwidth as a width of the page, and set that too.
 
Seems a little non intuitive that I need to tell the table 3 times what the width is 
(in my case at least, first all the columns, then the total : add all columns, then 
the percentage of the table according to the page width).
But anyways I have a workaround.
The bug is not the rowheight, but that totalwidth is not honored when adding to a 
document, it's only used for calculating rowheight and not for outputting the table? 
In any case life would be easier if there was a method on the document that could do 
that calculation (it's very easy, but I tend to like to do this in one place, and the 
document seems fit to this task).
float pctWidth = document.getWidthPercentage(table.getTotalWidth);
table.setWidthPercentage(pctWidth);
 
And furthermore it would be nice if this was documented better, and saying that, I 
would be happy to document some of this, and provide examples.
 
Thanks again Paulo, it's been a big help in our further use of the library.
 
Thanks,
NEKO

        -----Original Message----- 
        From: Paulo Soares [mailto:[EMAIL PROTECTED] 
        Sent: Mon 2/23/2004 22:28 
        To: Nikolaj Brinch Joergensen 
        Cc: [EMAIL PROTECTED] 
        Subject: Re: [iText-questions] Problems with getRowHeight of PdfPTable
        
        

        There's no bug. You are measuring the height with a width but creating the
        final table with a different width. To see what's really happeneing change
        the main() method to:
        
         public static void main(String[] args) throws Exception {
          System.out.println("Writing document...");
          OutputStream outputStream = new FileOutputStream("c:\\reperror.pdf");
        
          Document document = new Document(PageSize.A4, 50, 50, 50, 50);
          PdfWriter writer = PdfWriter.getInstance(document, outputStream);
          document.open();
        
          PdfPTable pdfTable = new PdfPTable(new float[] {_rowLabelWidth, 4 *
        _columnLabelWidth});
                pdfTable.setTotalWidth(_rowLabelWidth + 4 * _columnLabelWidth);
        
          PdfPTable rowLabels = createRowLabels();
          PdfPTable cells = createCells();
        
          pdfTable.addCell(newCell(rowLabels));
          pdfTable.addCell(newCell(cells));
        
                pdfTable.writeSelectedRows(0, -1, 50, 750,
        writer.getDirectContent());
        
          document.close();
          System.out.println("Done!");
         }
        
        To have the required effect change:
        
        private static float _rowLabelWidth = 100f;
        
        Best Regards,
        Paulo Soares
        
        ----- Original Message -----
        From: "Nikolaj Brinch Joergensen" <[EMAIL PROTECTED]>
        To: "Paulo Soares" <[EMAIL PROTECTED]>
        Sent: Monday, February 23, 2004 12:53
        Subject: RE: [iText-questions] Problems with getRowHeight of PdfPTable
        
        
        Thanks Paulo.
        
        
        
        Please tell me if I can help with more information?
        
        
        
        I can reproduce this very simply (I've made a bug report on SourceForge,
        with a simple example).
        
        
        
        Thanks,
        
        NEKO
        
        
        
        -----Original Message-----
        From: Paulo Soares [mailto:[EMAIL PROTECTED]
        Sent: 23. februar 2004 13:40
        To: Nikolaj Brinch Joergensen; [EMAIL PROTECTED]
        Subject: RE: [iText-questions] Problems with getRowHeight of PdfPTable
        
        
        
        I'll have a look into that.
        
        Best Regards,
        Paulo Soares
        
        -----Original Message-----
        From:   [EMAIL PROTECTED]
        [SMTP:[EMAIL PROTECTED] On Behalf Of Nikolaj
        Brinch Joergensen
        
        Sent:   Saturday, February 21, 2004 11:14
        To:     [EMAIL PROTECTED]
        Subject:        [iText-questions] Problems with getRowHeight of PdfPTable
        
        
        
        Hi,
        
        Thank you for the very best PDF Library for Java.
        
        I have come across a problem that is stopping me in my use of this.
        
        It seems that PdfPTable is giving me back wrong heights when I cell
        getRowHeight(int idx).
        
        I've attached the code to reproduce this.
        
        It seems that my vertical labels returns
        
        28.0
        
        28.0
        
        16.0
        
        28.0
        
        16.0
        
        16.0
        
        When that should have been
        
        28.0
        
        16.0
        
        16.0
        
        16.0
        
        16.0
        
        16.0
        
        According to the output in the PDF, and also if I hard code the heights,
        this is what appears to be the right thing.
        
        Please tell me if I'm doing anything wrong, or if there really is a bug?
        
        Thanks,
        
        NEKO
        
        
        
        <<CrossTab.java>>
        
        SAS Forum International Copenhagen 2004 - Bella Centret, 15.-17. juni
        
        Tilmeld dig nu: www.sas.com/dk/sasforum <http://www.sas.com/dk/sasforum>
        
         << File: CrossTab.java >>
        
        
        SAS Forum International Copenhagen 2004 - Bella Centret, 15.-17. juni
        
        Tilmeld dig nu: http://www.sas.com/dk/sasforum
        
        
        
        


SAS Forum International Copenhagen 2004 - Bella Centret, 15.-17. juni

Tilmeld dig nu: http://www.sas.com/dk/sasforum




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to