Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带页眉和页脚文本的itextsharp多页表格 我试图创建一个PDF生成器,它在页面的顶部和底部有一些文本,中间有一个表。表格设置为合适的行长度。除了PdfPTable表保留了先前添加的行的值之外,其他一切都正常工作,因此当我输出pdf时,它保留了最后一个表。是否有方法添加具有相同变量的新表或清除当前变量 doc.Open(); Paragraph header = new Paragraph("header"); header.Alignment = Element.ALIGN_CENTER; Paragraph footer = new Paragraph("footer"); footer.Alignment = Element.ALIGN_CENTER; PdfPTable table = new PdfPTable(3); table.LockedWidth = true; table.SetWidths(widths); table.HorizontalAlignment = 0; foreach (T t in results) { if (counter % 50 == 0) { if (counter != 0) { doc.Add(table); doc.Add(footer); doc.NewPage(); } doc.Add(header); table.AddCell("Name"); //Table Header table.AddCell("Address"); //Table Header table.AddCell("Phone"); //Table Header } table.AddCell("First Last"); //individual cell from t.name table.AddCell("Address"); //individual cell from t.address table.AddCell("Phone"); //individual cell from t.phone } doc.Add(table); doc.Add(footer); doc.Close();_C#_Pdf_Itext - Fatal编程技术网

C# 带页眉和页脚文本的itextsharp多页表格 我试图创建一个PDF生成器,它在页面的顶部和底部有一些文本,中间有一个表。表格设置为合适的行长度。除了PdfPTable表保留了先前添加的行的值之外,其他一切都正常工作,因此当我输出pdf时,它保留了最后一个表。是否有方法添加具有相同变量的新表或清除当前变量 doc.Open(); Paragraph header = new Paragraph("header"); header.Alignment = Element.ALIGN_CENTER; Paragraph footer = new Paragraph("footer"); footer.Alignment = Element.ALIGN_CENTER; PdfPTable table = new PdfPTable(3); table.LockedWidth = true; table.SetWidths(widths); table.HorizontalAlignment = 0; foreach (T t in results) { if (counter % 50 == 0) { if (counter != 0) { doc.Add(table); doc.Add(footer); doc.NewPage(); } doc.Add(header); table.AddCell("Name"); //Table Header table.AddCell("Address"); //Table Header table.AddCell("Phone"); //Table Header } table.AddCell("First Last"); //individual cell from t.name table.AddCell("Address"); //individual cell from t.address table.AddCell("Phone"); //individual cell from t.phone } doc.Add(table); doc.Add(footer); doc.Close();

C# 带页眉和页脚文本的itextsharp多页表格 我试图创建一个PDF生成器,它在页面的顶部和底部有一些文本,中间有一个表。表格设置为合适的行长度。除了PdfPTable表保留了先前添加的行的值之外,其他一切都正常工作,因此当我输出pdf时,它保留了最后一个表。是否有方法添加具有相同变量的新表或清除当前变量 doc.Open(); Paragraph header = new Paragraph("header"); header.Alignment = Element.ALIGN_CENTER; Paragraph footer = new Paragraph("footer"); footer.Alignment = Element.ALIGN_CENTER; PdfPTable table = new PdfPTable(3); table.LockedWidth = true; table.SetWidths(widths); table.HorizontalAlignment = 0; foreach (T t in results) { if (counter % 50 == 0) { if (counter != 0) { doc.Add(table); doc.Add(footer); doc.NewPage(); } doc.Add(header); table.AddCell("Name"); //Table Header table.AddCell("Address"); //Table Header table.AddCell("Phone"); //Table Header } table.AddCell("First Last"); //individual cell from t.name table.AddCell("Address"); //individual cell from t.address table.AddCell("Phone"); //individual cell from t.phone } doc.Add(table); doc.Add(footer); doc.Close();,c#,pdf,itext,C#,Pdf,Itext,我可以通过添加:table=newpdfptable(5)在if语句中if(counter!=0)您的代码非常奇怪。你从哪里得到灵感的?您是否阅读过添加页眉和页脚的页面事件?你读过关于表格页眉和表格页脚的内容吗?另外:如果继续使用同一个表实例,为什么表会保留其行?您没有在任何地方增加计数器。我想更正你的代码,但我不知道你的代码应该做什么。不增加计数器是没有意义的。那个计数器变量是干什么的?就好像你读过一些关于使用PdfPTable作为LargeElement的东西,但却不明白那是怎么回事。如果你

我可以通过添加:
table=newpdfptable(5)在if语句中
if(counter!=0)

您的代码非常奇怪。你从哪里得到灵感的?您是否阅读过添加页眉和页脚的页面事件?你读过关于表格页眉和表格页脚的内容吗?另外:如果继续使用同一个表实例,为什么表会保留其行?您没有在任何地方增加
计数器。我想更正你的代码,但我不知道你的代码应该做什么。不增加计数器是没有意义的。那个
计数器
变量是干什么的?就好像你读过一些关于使用
PdfPTable
作为
LargeElement
的东西,但却不明白那是怎么回事。如果你不回复我的评论,我将通过以下答案来结束您的问题:对不起,我不熟悉使用堆栈溢出来回答问题,我通常会找到我要找的内容。我对大部分代码进行了条带化,试图显示特定的问题,但我想我没有分享足够的信息。foreach循环中有一个计数器+。我确实读过页眉和页脚事件,但它们没有以我需要的方式实现。下次我会尽量把我的问题讲清楚。似乎很难相信这能解决问题,但如果你这么说。。。