Skip to main content
Skip table of contents

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?

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 How to add a border to a paragraph? if you want to see how to answer this question in iText 5.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.