Bruno Lowagie wrote:
> It's explained well, and you're not doing anything wrong.
> It's just that iText is designed to do what you describe
> (show the content as soon as possible) and nobody seems
> to have the time to implement something that would make
> iText behave the way you want it.
> br,
> Bruno

Hi Bruno,

thank you very much for your answer. I think my explanation was at least a 
bit unclear. By now I have solved the problem and I think I have 
understood why it had occured... I will explain the details below for 
others that may have the same problem.


Brief description of what I want to do reduced to minimum needed:
One column with a long text that can last a few pages;
Another column filled up with new lines (\n) that display text (price 
etc.) in the line where the text of the first column ends (ALIGN_BOTTOM).
These columns should have a line spacing that makes them more readable.


The way of realisation that leads to the problem:
I cut the long text line by line and put every line in a new Paragraph and 
setSpacingAfter to the wanted value. After that I add every Paragraph with 
the addElement (composite!) method to the cell.

This also works fine if the long text isn't too long. But if it is long 
enough, the second column is filled with text on the bottom of the page 
before the long text ends. I think it has something to do with the way 
setSpacingAfter works internally. I haven't taken a look into the code, 
but I believe it works similar to the multiplied leading method (Absolute 
Spacing/Leading = Multiplied Value * maxFontSize where maxFontSize is the 
size of the bigest font in the line). Now the main question: How big is 
the bigest font in the line for a line of "\n" compared to a usual line? 
The solution: Simply not big enough when the text in the first column is 
to long. The spacing for each of the blank lines (second column) is 
smaller than the spacing of the text lines (first column). When summing 
this spacing up for each column the second column doesn't have enough 
content to fill the page before the last page.


The correct way of realization:
First column: 
PdfPCell cell = new PdfPCell(new Phrase("whole long text that lasts over a 
few pages"));
cell.setLeading(0,1.6F);

Second column:
PdfPCell cell = new PdfPCell(new Phrase("a lot of new lines and finally 
the line that should display in the last row of the other columns long 
text"));
cell.setLeading(0,1.6F);

Now the leading is the same for lines with text and empty lines. Works 
perfect. 

Thank you for the great tool.

Best regards,
Benjamin
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to