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 give an image rounded corners?

I want to get the image width and height and make the edges of the image curved.

31st May 2016

admin-marketing

I'm using iTextSharp to export images into a PDF. Now I want to get the image width and height (while getting the image from disk) and make the edges of image curved (rounded corners). I get and add the image like this:

The width and height of this image are gif.getImageScaledWidth() andgif.getImageScaledHeight()` respectively. There are other ways to get the width and the height, but this way always gives you the size in user units that will be used in the PDF.

If you do not scale the image, above methods will give you the original size of the image in pixels. Pixels will be treated as user units by iText. In PDF, a user unit corresponds with a point by default (and 72 points correspond with 1 inch).

Question 2: How do you display the image with rounded corners?

Some image formats (such as PNG) allow transparency. You could create an image in such a way that the effect of rounded corners is mimicked by making the corners transparent.

If this is not an option, you should apply a clipping path. This is demonstrated in the ClippingPath example in chapter 10 of my book.

How to preserve high resolution images in PDF?

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.