Hi following is my code for creating a pdf report.
string strQuery = "select stdid,class name1,name2,surname,fname,mname,section,room,house from stdmst1 where class=10 ";
//SqlCommand cmd = new SqlCommand(strQuery, con);
SqlCommand cmd = new SqlCommand(strQuery);
DataTable dt = GetData(cmd);
GridView GridView1 = new GridView();
GridView1.AllowPaging = false;
GridView1.DataSource = dt;
GridView1.DataBind();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=DataTable.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.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, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
the code doesn't contains any error.
problem is it will not download to browser or directly views in browser.
my requirement is to view in browser directly.
it will work only if there exists a third party downloadmanager like IDM.
How to solve this
Regards
Baiju