Different concepts are at play when adding text to a cell.
- padding is the extra space inside the borders of the cell. It's similar to the concept with the same name in HTML. You can change the padding of a cell with the
- leading is the space between two lines. Even when there's only one line, this leading will be used to determine the baseline of the text. By default the leading is 1.5 times the font size. If you're working in text mode, the leading of a cell is set using the
setLeading(); you can define a fixed leading (
fixedLeading), or a leading that depends on the font size (
multipliedLeading). This value is ignored if you're working in composite mode. In composite mode, the leading of the separate
Elements added to the cell is used.
- ascender and descender are two value that are font-specific. The ascender is a value that tells you how much space is needed above the baseline of the text; the descender is a value that tells you how much space is needed below the baseline of the text. You can tell iText to take these values into account with the methods
So, if you want the cell to have a minimal size, you need to set the padding to 0, the leading to match the size of the font, and tell iText to use the ascender and descender value.
DISCLAIMER: in the past, we've received reports from customers that showed us that not all fonts contain the correct ascender and descender information. This needs to be fixed at the font level.