Reputation: 1643
In iText7 I need to create 5 lines of text at the top of a document that are centered to the page. The easiest way I found to do this is:
doc.add(new Paragraph("text of line 1").SetTextAlignment(TextAlignment.CENTER));
doc.add(new Paragraph("text of line 2").SetTextAlignment(TextAlignment.CENTER));
etc. However there is a larger amount of space between each of the lines than I want. Within a paragraph you can set line leading, but how do I set leading between paragraphs in a document? Or am I doing this the complete wrong way to begin with?
Upvotes: 4
Views: 13418
Reputation: 187
In my case with iText7, I used SetMarginTop(0f) and SetMarginBottom(0f) to make it.
Upvotes: 4
Reputation: 9012
Paragraph has 2 methods for handling what is known as the leading.
Paragraph o1 = new Paragraph("");
o1.setMultipliedLeading(1.0f);
Multiplied leading is when you specify a factor of how big the leading will be compared to the height of the font.
You can also set it document wise:
document.setProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, 1.2f));
Upvotes: 8