From:
Bruno Lowagie <[EMAIL PROTECTED]>
To:
Post all your questions about iText here
<itext-questions@lists.sourceforge.net>
Date:
05/16/2008 08:40 AM
Subject:
Re: [iText-questions] Further Testing - RE: Confusing Cell Hight numbers
=>[EMAIL PROTECTED] wrote:
=>>
=>> Ok, I have done some further testing and have found the following
=>> possible bug...
=>
=>It's NOT a bug; it's wrong use of iText.
=>You didn't understand Paulo's advice:
=>"PdfPTable.getRowHeight(). You must set the total width first."
=>
=>I don't know if you already have the book, but
=>the combination of these two lines doesn't make sense:
=>
=>doutTable.setWidthPercentage(100);
=>doutTable.setTotalWidth(24.0f);
:) Your right Bruno, I didn't quite understand the difference between the
two. Now I do.. :)
The Book just arrived last night and I plan on reading it over the
weekend.. :)
But I will say this, before I had the setTotalWidth, I would not be able
to calculate the row height.
Once I added the setTotalWidth I was able to get the row Height.
No need to comment on these last 2 lines as I see the errors of my way..
:)
=>Either you want to set the width as a percentage (100%)
=>or you want to set the width absolutely, but in your case
=>the second line is ignored, because you didn't do:
=>
=>doutTable.setLockedWidth(true);
=>
=>And even if you add that line, it would lead to a very ugly
=>result because 24pt is very small for a table.
=>
=>What you need is:
=>
=>doutTable.setTotalWidth(document.right() - document.left());
=>doutTable.setLockedWidth(true);
=>
=>If the "width" is "locked", iText knows it should use that value
=>AND it will ignore the width percentage (so you might as well
=>drop that line).
=>
=>So far for the solution to your problem.
Thank you so much that now makes perfect sense, I am not sure why I missed
it...
=>Now for your allegation that this is a bug in iText.
I do want to point out I said "possible bug", as in I was not sure if it
was me or iText.. Now I know it was me.. :)
=>
=>It would go against any logic if iText was able to get the height
=>of the first row right in your example. That would be simply
=>impossible! (And "in this house we obey the rules of thermodynamics!")
That is strange because as soon as I created the last cell in that row and
added it to the table, I am able to get the height..
Hmmm, I have some re-thinking to do here..
=>
=>Why impossible? Well, you create a table object with a width of 100%.
=>Then you add enough cells to fit one row and you ask the
=>height of that row. But you didn't add the table to the document yet!
=>There is no way for the table to know the available width. It's 100%
=>of what? Of 24pt? By the way, where did you get that value? It looks
No the number wasn't arbitrarily chosen..
When I created the table with widths "float[] widths3 = {0.5f, 6.0f, 1.0f,
1.0f};"
and I printed a page that looked perfect, I used a ruler and did some
calculations and arrived at that number..
2 cm = 1.2f so a page being 21.5 cm is about 24.0f.. Obviously that was
WAY off..
After reading what you just pointed out, I see my errors.. Now that I
have the book I will be prone to making less of these stupid errors.
=>like you chose a number arbitrarily. The table object can't know this
=>until you add the table to the document. At that moment, you commit
=>that table to a specific document, with a specific width
=>(document.right() - document.left()) and because of that,
=>the height of the rows following that first row can be calculated
=>correctly.
=>
=>best regards,
=>Bruno
=>
=>-------------------------------------------------------------------------
=>This SF.net email is sponsored by: Microsoft
=>Defy all challenges. Microsoft(R) Visual Studio 2008.
=>http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
=>_______________________________________________
=>iText-questions mailing list
=>iText-questions@lists.sourceforge.net
=>https://lists.sourceforge.net/lists/listinfo/itext-questions
=>
=>Do you like iText?
=>Buy the iText book: http://www.1t3xt.com/docs/book.php
=>Or leave a tip: https://tipit.to/itexttipjar
Glen Hamel
Lead Programmer / Technician
Auric Networks Canada, Inc.
570 Orwell Street, Unit 1
Mississauga, Ontario
L5A 3V7
Phone 905.361.7621
Fax 905.274.3912
http://www.auricnet.ca
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar