【发布时间】:2015-04-04 23:23:55
【问题描述】:
我目前正在处理 PDF,但在尝试增加 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);
正如你从上面看到的,我正在尝试增加para 的行高,我已经尝试过para.SetLeading(0f, 2f),但它仍然没有增加行高或前导,因为它被称为。
这可能是什么问题?
【问题讨论】:
-
此问题与iText: maintain identing if paragraph takes new line in PdfPCell 不完全相同,但答案是相同的:您是在文本模式 中添加
Paragraph,而不是在复合模式。在您的情况下,PdfPCell的前导优先于Paragraph的前导(因为您已经注意到在 文本模式 中忽略了前导)。 -
太棒了!我已经通过使用
AddElement(para)来修复它,而不是在构造函数中对其进行初始化。您可能想将其发布在答案中,以便我可以将其标记为已回答,再次感谢!
标签: c# pdf pdf-generation itextsharp typography