Saturday 3 August 2013

Show pdf content in asp.net Page

    protected void Page_Load(object sender, EventArgs e)
    {
        ReadPdfFile();         
    }
    private void ReadPdfFile()
    {
        string path = @"C:\Documents and Settings\sujoy\Desktop\Read-Data-From-Excel\App_Data\Test.pdf";
        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);
        }

    }

No comments:

Post a Comment