Spacing between paragraphs

限于喜欢 提交于 2020-05-09 05:48:07

问题


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?


回答1:


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));


来源:https://stackoverflow.com/questions/43723166/spacing-between-paragraphs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!