Surya Narayana

Surya Narayana

  • NA
  • 3
  • 2.2k

Please help this below query

Sep 24 2012 2:24 AM
Hi Frriends,

I have created Pdf file from SharePoint List data
DataTable dt = GetProductsData();

            GridView GridView1 = new GridView();
            GridView1.DataSource = dt;
            GridView1.DataBind();

            Response.Clear();
            Response.Buffer = true;
            Response.Charset = "";
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=CustomerInfo.pdf");
            StringWriter sWriter = new StringWriter();
            HtmlTextWriter hTWriter = new HtmlTextWriter(sWriter);
            GridView1.RenderControl(hTWriter);
            StringReader sReader = new StringReader(sWriter.ToString());
            Document pdf = new Document(PageSize.A4);
            HTMLWorker worker = new HTMLWorker(pdf);
            PdfWriter.GetInstance(pdf, Response.OutputStream);
            pdf.Open();
            worker.Parse(sReader);
            pdf.Close();
            Response.Write(pdf);
            Response.Flush();
            Response.End();
its working fine but i want store this Pdf file in to my document library please can you help this query

Regards,
Surya


Answers (2)