Sir,
I am writing all contents inside a gridview to PDF.
It is generating a window with 'Open with' and 'Save' option.
Here my requirement is how to open that PDF without this window.
That means the open with event in popup window want to work in background..
Please help me.
Thanks in advance.
My code i am giving below..
This code is working perfectly with the open with window..
protected void imgPdf_Click(object sender, EventArgs e)
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
try
{
//To Export all pages
grdRequestList.AllowPaging = false;
BindGrid();
grdRequestList.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
HttpContext.Current.ApplicationInstance.CompleteRequest();
//PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
//Response.End();
}
catch (Exception Ex)
{
throw Ex;
}
}
}
}