Opening a .pdf file in new window
On the First page write the following code:-
string Url = "Wite the url of the page to be opened";
ClientScript.RegisterStartupScript(this.GetType(), "", "window.open('" + Url + "');", true);
On the second page (the page to be opened) write this on page load
string path = "Wite path of the pdf file to be opened";
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);
if (buffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
Note :- Please import the namespace "using System.Net" to use WebClient.
0 Comment(s)