G
Guest
Hello,
I need to open a PDF file in a new window in ASP.NET 1.1.
The problem is when I try to save the open PDF file the suggested name is
name of my new window (ShowDocument -> ShowDocument.pdf), how can I set it up
so it can be the filename of the file?
I am doing the following, on the page with the link to the PDF file I
RegisterNewPdfWindow("../Common/ShowDocument.aspx?file="+file,"showdocument");
being RegisterNewPdfWindow
protected void RegisterNewPdfWindow(string path,string name)
{
RegisterClientScriptBlock("plugin.js","<script
src=\"../js/plugins.js\"></script>\n");
StringBuilder sb=new
StringBuilder("window.open(\"").Append(path).Append("\",\"").Append(name).Append("\");\n");
string block=ComposeScriptBlock(sb.ToString());
RegisterStartupScript("pdfwindow",block);
}
On the Page_Load of ShowDocument.aspx
private void Page_Load(object sender, System.EventArgs e)
{
Page.Response.ClearContent();
Page.Response.ClearHeaders();
Page.Response.ContentType = "application/pdf";
Page.Response.WriteFile(file);
Page.Response.Flush();
Page.Response.Close();
}
Thanks in advance
I need to open a PDF file in a new window in ASP.NET 1.1.
The problem is when I try to save the open PDF file the suggested name is
name of my new window (ShowDocument -> ShowDocument.pdf), how can I set it up
so it can be the filename of the file?
I am doing the following, on the page with the link to the PDF file I
RegisterNewPdfWindow("../Common/ShowDocument.aspx?file="+file,"showdocument");
being RegisterNewPdfWindow
protected void RegisterNewPdfWindow(string path,string name)
{
RegisterClientScriptBlock("plugin.js","<script
src=\"../js/plugins.js\"></script>\n");
StringBuilder sb=new
StringBuilder("window.open(\"").Append(path).Append("\",\"").Append(name).Append("\");\n");
string block=ComposeScriptBlock(sb.ToString());
RegisterStartupScript("pdfwindow",block);
}
On the Page_Load of ShowDocument.aspx
private void Page_Load(object sender, System.EventArgs e)
{
Page.Response.ClearContent();
Page.Response.ClearHeaders();
Page.Response.ContentType = "application/pdf";
Page.Response.WriteFile(file);
Page.Response.Flush();
Page.Response.Close();
}
Thanks in advance