Reputation: 14717
Currently, I am using
document.add( Chunk.NEWLINE );
after each paragraph to generate space between two paragraphs. What is the way to generate a spacing of any height I specify?
Upvotes: 4
Views: 18900
Reputation: 77528
The space between two lines of the same Paragraph
is called the leading. See Changing text line spacing
If you want to introduce extra spacing before or after a Paragraph
, you can use the setSpacingBefore()
or setSpacingAfter()
method. See itext spacingBefore property applied to Paragraph causes new page
For instance:
Paragraph paragraph1 = new Paragraph("First paragraph");
paragraph1.setSpacingAfter(72f);
document.add(paragraph1);
Paragraph paragraph2 = new Paragraph("Second paragraph");
document.add(paragraph2);
This puts 72 user units of extra white space between paragraph1
and paragraph2
. One user unit corresponds with one point, so by choosing 72, we've added an inch of white space.
Upvotes: 13