iText pdf library
Website search

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? I mean 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 this link if you want to see how to answer this question in iText 5.

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now