我在使用 ITextSharp 的表格时遇到问题。我想要没有顶部和底部填充的单元格,以便它们彼此靠近。
虽然我已将单元格的填充和行距设置为 0,但空白仍然存在。
有谁知道如何删除空格?
编辑:
感谢 Dylan 的及时回答,我已经设法解决了我的问题。如果有人遇到类似问题,这里是源代码片段
Document document = new Document(PageSize.A4, 5, 5, 10, 10);
using (FileStream fs = new FileStream("C:\\Users\\brum\\Desktop\\untitled.pdf", FileMode.Create))
{
iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs);
document.Open();
PdfPTable table = new PdfPTable(2);
PdfPCell cell = new PdfPCell(new Phrase("Spanning 2 cols"));
cell.Colspan = 2;
cell.HorizontalAlignment = 1;
cell.Padding = 0f;
cell.UseAscender = true;
table.AddCell(cell);
table.AddCell("Next row 1");
table.AddCell("Next row 2");
document.Add(table);
document.Close();
}
cell.UseAscender = true;//这条线对我有用
最佳答案
将顶部内边距设置为较小甚至为负值。另一种选择是
PdfPCell.setUseAscender()
。
例如:
cell.setPaddingTop(0f); // No padding on top cell
或
cell.UseAscender = true;
请粘贴您的代码。
关于c# - ITextSharp 4.1.6。 PDF 表格 - 如何删除每个单元格顶部的空格? [填充和行距已设置为 0],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9672046/