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 to do this? Posted on StackOverflow on May 5, 2015 by Amit Das Please take

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.


Share this article

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
Contact

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