Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Vendors List.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
hw.Write("<center><h3>Vendors List</h3></center><br /><br /><br /><br />");
grdVendorList.AllowPaging = false;
grdVendorList.DataBind();
grdVendorList.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();