Recently we found Paul Madary's blog post about digital signatures in a Univeral Application (UWP) with iText 7, and we wanted to share it. Paul gracefully agreed to let us do that, and as a bonus we upgraded the code to be usable out-of-the-box with iText 7.1.3. The only change needed is the method SignDocumentSignature.

A big thank you to our Q3 top contributors!

There are so many people that contribute information to us in order to help improve our code, products and projects. We want to make sure that our top contributors are being recognized for the help they give and that they know how much we appreciate them.

Top menu

Breadcrumb

How to get rid of the top padding in a PdfPCell?

I'm creating labels (as in Avery labels) using tables.
Positioning of label elements requires some very tight tolerances in order to fit everything on the label.

31st May 2016

iText PDF

I have various zones on the label as PdfPCells. I need to fit text into these zones with 0 wasted space. But I always seem to have extra space at the top of the cell. This is best illustrated by using setVerticalAlignment(Element.ALIGN_TOP) which doesn't result in positioning the text near the top border of my cell, even with padding 0. How can I get rid of that top padding?

You talk about the top padding, but it isn't really a padding. It's the "leading". You are using the default font, which is Helvetica 12pt. The default leading is 1.5 times the font size. That's 18pt. The solution is to change the leading of a Paragraph (there is no Phrase class anymore). In iText 7 this is done in the following way:

Ready to use iText?

As always, if you have any technical questions, you can contact support with your valid support subscription or head over to one of our community support pages on Stack Overflow to see if your question has already been answered for our AGPL users.