[iText-questions] PdfPCell aligning to baseline rather than bottom of font?

2003-06-27 Thread Frederik MJ Sauer
While not really noticable at smaller font sizes, it appears that 
PdfPCell is placing it's phrase in such a way that roughly the baseline 
of the bottom is at the bottom of the cell, causing the lower part of of 
characters that drop below the line (e.g. pyj,qg) to cross over the 
bottom border of the cell. See, for example, the letter g in the word 
Testing as the font size increases in this example:

 PdfPTable ptable = new PdfPTable(1);
 ptable.getDefaultCell().setBorderColor(Color.RED);
 ptable.getDefaultCell().setBorder(Rectangle.BOX);
 ptable.getDefaultCell().setBorderWidth(.1f);
 ptable.addCell(new Phrase(Testing, 
FontFactory.getFont(FontFactory.COURIER, 7f)));
 ptable.addCell(new Phrase(Testing, 
FontFactory.getFont(FontFactory.COURIER, 10f)));
 ptable.addCell(new Phrase(Testing, 
FontFactory.getFont(FontFactory.COURIER, 20f)));
 ptable.addCell(new Phrase(Testing, 
FontFactory.getFont(FontFactory.COURIER, 30f)));
 ptable.addCell(new Phrase(Testing, 
FontFactory.getFont(FontFactory.COURIER, 40f)));

 document.add(ptable);

In examples/Chap0518.java it appears that a small font size and 
datatable.getDefaultCell().setPadding(3) are used. Certainly a padding 
can be used to prevent the lower part of the letters dropping through 
the bottom of the cell, but one must (re)adjust the padding based on the 
font size, and as the font size increases, the amount of 'extra' padding 
between the top of the phrase and the top border of the cell increases.

If this is not by design, could you point me to the section of code I 
can look at to fix this?

Keep up the good work, and thanks for the quick responses!

Fred





---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0016ave/direct;at.asp_061203_01/01
___
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] PdfPCell aligning to baseline rather than bottomof font?

2003-06-27 Thread Frederik MJ Sauer
Paulo,

I understand that your work-around is possible (setting padding 
manuall). I still feel like the functionality ought to be that the text 
by default in raised a bit to fit inside the cell, rather than have 
parts of the text sink through the bottom.

I attached an image of the PDF based on the sample code. Again, looking 
at the g in the word Testing, and the (default) space above the word 
Testing in the largest font example, I think you can see what I mean.

(This sample is using the 1.00 jar by the way)

Thanks again
Fred

You can set the padding individually for each border (top, bottom, left,
right).
 

While not really noticable at smaller font sizes, it appears that
PdfPCell is placing it's phrase in such a way that roughly the baseline
of the bottom is at the bottom of the cell, causing the lower part of of
characters that drop below the line (e.g. pyj,qg) to cross over the
bottom border of the cell. See, for example, the letter g in the word
Testing as the font size increases in this example:
 PdfPTable ptable = new PdfPTable(1);
 ptable.getDefaultCell().setBorderColor(Color.RED);
 ptable.getDefaultCell().setBorder(Rectangle.BOX);
 ptable.getDefaultCell().setBorderWidth(.1f);
 ptable.addCell(new Phrase(Testing,
FontFactory.getFont(FontFactory.COURIER, 7f)));
 ptable.addCell(new Phrase(Testing,
FontFactory.getFont(FontFactory.COURIER, 10f)));
 ptable.addCell(new Phrase(Testing,
FontFactory.getFont(FontFactory.COURIER, 20f)));
 ptable.addCell(new Phrase(Testing,
FontFactory.getFont(FontFactory.COURIER, 30f)));
 ptable.addCell(new Phrase(Testing,
FontFactory.getFont(FontFactory.COURIER, 40f)));
 document.add(ptable);

In examples/Chap0518.java it appears that a small font size and
datatable.getDefaultCell().setPadding(3) are used. Certainly a padding
can be used to prevent the lower part of the letters dropping through
the bottom of the cell, but one must (re)adjust the padding based on the
font size, and as the font size increases, the amount of 'extra' padding

between the top of the phrase and the top border of the cell increases.

If this is not by design, could you point me to the section of code I
can look at to fix this?
Keep up the good work, and thanks for the quick responses!

Fred


inline: sample.png

[iText-questions] re: leading inside cells

2003-06-26 Thread Frederik MJ Sauer


Quoting Somik Raha [EMAIL PROTECTED]:

 Hi,
 I'm finding that leading (within Phrases or Paragraphs) is not honored
 inside a cell, but works fine outside. Is this a known bug ? 

Cell has its own setLeading.
It overrules all other leadings.
Bruno

This seems too restrictive since a given cell can only have a single 
value for 'leading'. For example, on an invoice one might want to have 
the name of the company in a large font, followed by several address 
lines (paragraphs) in a smaller font. Thus, the line spacing (leading) 
between the first two paragraphs needs to be different than the leading 
between subsequent paragraphs.

Simply adding the paragraphs in the above example to the document works 
(i.e. line spacing is okay). However, when more layout control is needed 
for the invoice and this code is changed to instead add paragraphs to a 
table cell (so that the top of the invoice can be layed out into rows 
and columns) the cell leading for all paragraphs is suddenly set to the 
leading based on the large font of the first paragraph. One can override 
the cell leading, but it affects all paragraphs in the cell.

As a work-around you can add a sub table (consisting of 1 column and 2 
rows), separting the large font paragraph from the smaller font 
paragraphs into two separate cells. This seems needless painful, though.

Maybe I'm missing an important reason why the cell leading behaves in 
this way? Is there maybe a simple way to wrap the paragraphs into some 
type of chunk before it is placed in the table cell?

Please help.

Thanks
Fred
P.S. iText is GREAT! Keep up the good work!



---
This SF.Net email is sponsored by: INetU
Attention Web Developers  Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
___
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions