更好的代码呢? [英] better code for this?

查看:79
本文介绍了更好的代码呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试生成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

推荐答案

您应该使用ItextSharp在pdf文档中创建自定义表格

尝试此链接,这将对您有所帮助.
http://www.dotnetspark.com/kb/1365- create-custom-table-pdf-document-using-itextsharp.aspx [
You should look creating custom table in pdf document using ItextSharp

Try this link, this will be helpful to you.
http://www.dotnetspark.com/kb/1365-create-custom-table-pdf-document-using-itextsharp.aspx[^]

Hope this helps.
cheers


这篇关于更好的代码呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆