How can I reduce the height of a line break which occurs when a paragraph length is too long for the width of the ColumnText?
I've tried the following, as I've seen other questions which answered with this:
p.Leading = 0
But this has made no affect.
I've also tried increasing the Leading
to 100
to see if a larger line break is added, but neither work.
SpacingBefore/SpacingAfter doesn't help either:
p.SpacingBefore = 0
p.SpacingAfter = 0
How can I reduce this?
When using a table, you need to set the leading on the cell itself. However, you'll see that the Leading
property is read-only so instead you'll need to use the SetLeading()
method which takes two values, the first is the fixed leading and the second is the multiplied leading. According to this post here:
Multiplied basically means, the larger the font, the larger the leading. Fixed means the same leading for any font size.
To shrink the leading to 80% you'd use:
Dim P1 As New Paragraph("It was the best of times, it was the worst of times")
Dim C1 As New PdfPCell(P1)
C1.SetLeading(0, 0.8)
EDIT
Sorry, I saw "Column" and my coffee-lacking brain went to tables.
For a ColumnText
you should be able to use the Paragraph's leading values just fine.
Dim cb = writer.DirectContent
Dim ct As New ColumnText(cb)
ct.SetSimpleColumn(0, 0, 200, 200)
Dim P1 As New Paragraph("It was the best of times, it was the worst of times")
''//Disable fixed leading
P1.Leading = 0
''//Set a font-relative leading
P1.MultipliedLeading = 0.8
ct.AddElement(P1)
ct.Go()
On my machine running iTextSharp 5.1.2.0 this produces two lines of text that are slightly squished together.