gpt4 book ai didi

c# - iTextSharp - 段落行高

转载 作者:行者123 更新时间:2023-11-30 14:53:49 27 4
gpt4 key购买 nike

我目前正在处理 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) 但是它仍然没有增加所谓的行高或行距。

这可能是什么问题?

最佳答案

您在文本模式中添加para,而不是在复合模式中添加。文本模式意味着 PdfPCell 的前导将优先于为 Paragraph 定义的前导。对于复合模式,情况正好相反。

你可以通过一个小的改变来解决这个问题:

cell = new PdfPCell();
cell.addElement(para);
tempTable.AddCell(cell);

使用 addElement() 方法使 cell 从文本模式切换到复合模式。

关于c# - iTextSharp - 段落行高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28338319/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com