Skip to main content
Skip table of contents

How does a PdfPCell's height relate to the font size?


In iText, what is the minimum height of a PdfPCell for which a given size of font text is visible?


Is there any ratio between PdfPCell and font size? I am making a PDF with pages of size A3, A4 and A5. I need to know the relation between Font size and PdfPCell minimum height, so that the text will be visible.

Posted on StackOverflow on Sep 3, 2013 by MGDroid

In iText 7 we can work with cells in composite mode only, so we can not work with leading and Ascender / Descender. These values depend on the elements which you add into the cell. But still you can set the padding:

  • 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 setPadding() method.

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.

Click How does a PdfPCell's height relate to the font size? if you want to see how to answer this question in iText 5.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.