ITextSharp 4.1.6。 PDF表 - 如何删除每个单元格顶部的空格? [填充和前导已设置为0] [英] ITextSharp 4.1.6. PDF Table - how to remove whitespace on top of each cell? [padding and leading already set to 0]
问题描述
我遇到了ITextSharp表的问题。我想要没有top& amp;底部填充,以便它们彼此靠近。
I'm having a problem with ITextSharp's tables. I'd like to have cells without top & bottom padding, so that they are placed closer to each other.
虽然我已将填充和单元格的前导设置为0,但仍保留空白区域。
Although I have set the padding and the leading of the cell to 0, the white-space still remains.
有没有人知道如何删除空格?
Does anyone please know how to remove the whitespace ?
编辑:
Thanx提示Dylan回答,我已成功解决了我的问题。如果有人遇到类似问题,这是源代码段
Thanx to prompt answer from Dylan, I've managed to resolve my issue. Here's the source snippet if someone gets across similar issue
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()
。
Set the top padding to something small or even negative. Another option is
PdfPCell.setUseAscender()
.
ex:
cell.setPaddingTop(0f); // No padding on top cell
或
cell.UseAscender = true;
请粘贴您拥有的代码。
Please paste the code you have.
这篇关于ITextSharp 4.1.6。 PDF表 - 如何删除每个单元格顶部的空格? [填充和前导已设置为0]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!