user1578872
user1578872

Reputation: 9038

Adding gray line b/w paragraph in iText 7

I am not sure how to add the gray line like in the image b/w paragraphs in Itext 7.

Should I use rectangle for this with very small width and the whole page length?

Rectangle rect= new Rectangle(1, 400);

How to get whole page length as opposed to hard code the same?

enter image description here

Upvotes: 0

Views: 113

Answers (1)

Alexey Subach
Alexey Subach

Reputation: 12312

You can use the following piece of code:

Document document = new Document(pdfDocument);

document.add(new Paragraph("Hello"));
document.add(new Div().setHeight(5).setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.add(new Paragraph("World"));

document.close();

To achieve the result as displayed on the image:

result

Upvotes: 1

Related Questions