使用数据库值填充iTextSharp pdf

时间:2013-05-18 12:28:47

标签: c#-4.0 itextsharp

我在下面有这段代码,并尝试使用数据库中的值填充我的pdf。

 PdfPCell points = new PdfPCell(new Phrase("and is therefore entitled to ", arialCertify));
points.Colspan = 2;
points.Border = 0;
points.PaddingTop = 40f;
points.HorizontalAlignment = 1;//0=Left, 1=Centre, 2=Right
// code below needs attention
var cID = "ALFKI";
var xw = Customers.First(p => p.CustomerID ==cID);
table.AddCell(xw.CompanyName.ToString());

我无法弄清楚我哪里出错了。当我删除“下面的代码需要注意”下的代码时它可以工作,但我需要数据库值。

我正在使用带有ItextSharp的webmatrix。如果您需要进一步的代码,请告诉我。

1 个答案:

答案 0 :(得分:0)

PdfPCell cell=new PdfPCell(new Phrase(xw.CompanyName.ToString()));
cell.setColspan(numColumns);
table.addCell(cell);
document.add(table);
相关问题