Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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
 
Share this answer
 
Comments
Sandip.Nascar 24-Aug-12 2:14am    
I think this is a version issue. Check which version you are using. You can get the latest dll from open source.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900