How to add a border to a paragraph?

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

31st May 2016

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.


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