How to add a border to a paragraph?

Category: 
Tags: page eventsParagraphborderiText 7

I've created a Paragraph using iText. Now I have to add a border to this paragraph, not to the whole document. How to do this?

Posted on StackOverflow on May 5, 2015 by Amit Das

Please take a look at the BorderForParagraph and BorderForParagraph2 examples. They show how to add a border for a paragraph by extending ParagraphRenderer and overriding the drawBorder() method.

But iText 7 offers a much more easier way to achieve what you want:

paragraph.setBorder(new SolidBorder(1));

Here it is!

Click this link if you want to see how to answer this question in iText 5.