My requirement is generating a itextsharp pdf file in button_click event on the fly without saving it in Local disk and there should be no save dialogue . Once the PDF is created we have to display it inside a div tag within the same asp.net page in a small size.
Below is the code in which I am able to generate the PDF:
protected void Button2_Click(object sender, EventArgs e)
{
string PDFfileName = Path.GetFileNameWithoutExtension(fileName);
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "inline;filename= " +
PDFfileName + ".pdf");
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Document pdfDoc = new Document(); PdfWriter.GetInstance(pdfDoc,
HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
pdfDoc.Close();
HttpContext.Current.Response.Write(pdfDoc);
HttpContext.Current.Response.End();
}
Now the challenge which I am facing:
- The generated PDF is getting opened in entire page like redirection but the URL remains the same.(If we click back button of browser, it is going to the page where I clicked the button to generate pdf)
2)I am not able to display the generated PDF inside the div as a small part.
Solution which I want is the same pdf which is generated without saving it in disk should directly appear inside div tag in middle of the page and also it should not show any save dialogue message.
Please help me.