Cur*_*urt 4 line-breaks itextsharp paragraph
当段落长度对于ColumnText的宽度太长时,如何减少换行符的高度?
我已经尝试了以下内容,因为我已经看到了其他问题,并回答了这个问题:
p.Leading = 0
Run Code Online (Sandbox Code Playgroud)
但这没有任何影响.
我也尝试增加Leadingto 100以查看是否添加了更大的换行符,但都没有工作.
SpacingBefore/SpacingAfter也没有帮助:
p.SpacingBefore = 0
p.SpacingAfter = 0
Run Code Online (Sandbox Code Playgroud)
我怎样才能减少这个?
使用表时,需要在单元格本身上设置前导.但是,您将看到该Leading属性是只读的,因此您需要使用SetLeading()带有两个值的方法,第一个是固定前导,第二个是乘法前导.根据这篇文章:
乘法基本上意味着,字体越大,前导越大.固定意味着与任何字体大小相同.
要将领先缩减至80%,您需要使用:
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)
Run Code Online (Sandbox Code Playgroud)
编辑
对不起,我看到了"柱子",我缺乏咖啡的大脑进入了桌子.
对于ColumnText你应该能够使用段落的主导值就好了.
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()
Run Code Online (Sandbox Code Playgroud)
在我运行iTextSharp 5.1.2.0的机器上,这会生成两行文本,这些文本略微挤压在一起.