我使用ItextSharp创建PDF文档,但在创建每个页面上重复的标题表时遇到了问题。
我有一个函数,它以这样的方式创建这个表的布局:
public PdfPTable createTabHeader()
{
PdfPTable tableIntestazione = new PdfPTable(2);
PdfPCell cell = new PdfPCell(new Phrase("Rendicontazione"));
cell.Border = 0;
cell.BorderWidthBottom = 1;
cell.BorderColorBottom = BaseColor.LIGHT_GRAY;
cell.PaddingTop = 45;
tableIntestazione.AddCell(cell);
cell = new PdfPCell();
iTextSharp.text.Image imgLogo = iTextSharp.text.Image.GetInstance(ConfigurationManager.AppSettings["imgLogo"]);
imgLogo.ScalePercent(10);
imgLogo.Alignment = iTextSharp.text.Image.ALIGN_RIGHT;
cell.AddElement(imgLogo);
cell.Border = 0;
cell.HorizontalAlignment = 2;
cell.BorderWidthBottom = 1;
cell.BorderColorBottom = BaseColor.LIGHT_GRAY;
tableIntestazione.AddCell(cell);
tableIntestazione.HeaderRows = 1;
return tableIntestazione;
}我在网上读到属性"HeaderRows“允许在每个页面上显示表头,但在我的例子中,它完全隐藏了这个表。你能帮帮我吗?
发布于 2014-04-22 14:51:50
没有显示表是正常的:您正在创建一个包含两个列的表,其中添加了两个单元格。这意味着您有一个由单个行组成的表。将此行定义为标题行。现在,您有了一个只有一个标题行而没有body行的表。由于没有主体行,因此不会呈现标题行。如果有一个包含头而没有数据的表是没有意义的。
https://stackoverflow.com/questions/23222242
复制相似问题