iTextSharp - 段落线高度

Dan*_*Dan 3 c# pdf pdf-generation typography itextsharp

我目前正在研究PDF,但我正面临着试图增加a的行高的问题Paragraph,这是我现在的代码:

var tempTable = new PdfPTable(1);

cell = new PdfPCell(new Paragraph("My Account", GetInformationalTitle()));
cell.Border = Rectangle.NO_BORDER;
tempTable.AddCell(cell);

cell = new PdfPCell(new Paragraph("http://www.google.com/", GetInformationalOblique()));
cell.Border = Rectangle.NO_BORDER;
cell.PaddingBottom = 10f;
tempTable.AddCell(cell);

var para = new Paragraph("Login to 'My Account' to access detailed information about this order. " +
"You can also change your email address, payment settings, print invoices & much more.", GetInformationalContent());
 para.SetLeading(0f, 2f);

 cell = new PdfPCell(para);
 cell.Border = Rectangle.NO_BORDER;
 tempTable.AddCell(cell);
Run Code Online (Sandbox Code Playgroud)

正如你从上面所看到的,我正在尝试增加行高para,我已经尝试了para.SetLeading(0f, 2f)但它仍然没有增加行高或行距,因为它被称为.

这可能是什么问题?

Bru*_*gie 5

您将para文本模式中加入它,而不是复合模式.文本模式意味着领导者PdfPCell将获得优先于定义的领导者Paragraph.对于复合模式,它是另一种方式.

您可以通过一个小改动来解决这个问题:

cell = new PdfPCell();
cell.addElement(para);
tempTable.AddCell(cell);
Run Code Online (Sandbox Code Playgroud)

使用该addElement()方法可以cell从文本模式切换到复合模式.