-2

I am writing text into a ColumnText using

columnText.AddElement(paragraph);

I would like to have some padding (blank space) at the top and bottom of the column, bearing in mind that I am writing many paragraphs before reaching the bottom of the column. I would appreciate it if you give me an idea how to achieve this.

Filburt
  • 17,626
  • 12
  • 64
  • 115
ybel
  • 1
  • 2
  • I do not want a space after each paragraph. I need a space at the bottom of the Column (rectangle) only. To reach the bottom we need to add few paragraphs, for this reason SpaceAfter is not a solution. – ybel Nov 18 '16 at 09:33
  • 1
    In that case, why don't you update your question? Why are you asking to have space padding at the top of a column? You only want to check if the paragraph fits the column; if not, you want to forward it to the next column. That's how I interpret your question. In your comment, you don't mention the top of the column at all, which is confusing. – Bruno Lowagie Nov 18 '16 at 09:57

1 Answers1

-1

If you want to add more space before a Paragraph, you can do this:

paragraph.SpacingBefore = 10;

If you want to add more space after a Paragraph, you can do this:

paragraph.SpacingAfter = 10;

Note that the value of these properties are expressing in user units. By default 1 inch equals 72 user units.

If you want to change the distance between the lines of a Paragraph, change the leading: Changing text line spacing

Update:

In the comment, you are describing a situation in which you need to decide to add the full Paragraph in case it fits, or to move it to another column in case it doesn't fit.

The only way to achieve this, is to use ColumnText in simulation mode. Simulation mode means that you're not using ColumnText to actually add the content to the page. You are only adding the content to check whether or not the content was fully added, or to get the number of lines that were added, or to find out the Y position after adding the content. This principle has been explained many times before:

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • Yes, this would work if we want a space after a paragraph. In the case above I need a space at the bottom of the rectangle (column). If there is one remaining line left in that column, I should skip and add the text in the next column and leave the last line blank (this way if there is a background colour, it will look as a padding ). – ybel Nov 18 '16 at 09:43
  • 1
    I've updated my answer. Note that your question is probably phrased incorrectly. What you ask for in your comment is totally different from what you ask for in your question. – Bruno Lowagie Nov 18 '16 at 09:54