本文介绍了更好的代码呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试生成pdf文件.但是无法以pdf显示我的树记录.我不知道如何将数据表绑定到文档..
这是我的代码
hi i tried to generate pdf file.but am not able to display my tree records in pdf.i dont have idea how can i bind datatable to document..
here is my code
protected void GeneratePDFwithImage(string DID,string DocType)
{
string path = Server.MapPath("~/TenderDocument");
string fileName = "TPR1" + DateTime.Now.Ticks + ".pdf";
Document doc = new Document();
DataTable dtBidTree = new DataTable();
BidTreeBLL objBID = new BidTreeBLL();
dtBidTree = objBID.GetBidTree(DID, DocType);
try
{
if (dtBidTree.Rows.Count > 0)
{
int btParentNodeID;
string btName = string.Empty;
string btType = string.Empty;
string btDetails = string.Empty;
bool btChagable = false;
string sbtDID1 = string.Empty;
for (int m = 1; m < dtBidTree.Rows.Count; m++) // starting from 1 because, 0th row value not required
{
string NodeValue = string.Empty;
NodeValue=dtBidTree.Rows[m]["btNodeID"].ToString();
NodeValue=dtBidTree.Rows[m]["btParentNodeID"].ToString();
NodeValue = dtBidTree.Rows[m]["btName"].ToString();
NodeValue = dtBidTree.Rows[m]["btType"].ToString();
NodeValue = dtBidTree.Rows[m]["btDetails"].ToString();
NodeValue=dtBidTree.Rows[m]["btChangable"].ToString();
PdfWriter.GetInstance(doc, new FileStream(path + fileName, FileMode.Create));
doc.Open();
dtBidTree = objBID.GetBidTree(DID, DocType);
//doc.Add(new Paragraph("Hello World"));
//here doc.Add(NodeValue);but am getting error..so how can i bind to doc.add
//its generating only logo.
iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(Server.MapPath("~/images/CompanyLogo.JPG"));
doc.Add(gif);
}
}
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
finally
{
doc.Close();
}
}
请帮助我.谢谢您
please help me..thank you
推荐答案
这篇关于更好的代码呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!