Wednesday, 2 October 2013

Read PDF or Word File

string path = Server.MapPath("Some Useful Javascript Functions.docx");//pdf file or word file path
            WebClient client = new WebClient();
            Byte[] buffer = client.DownloadData(path);
            if (buffer != null)
            {
                Response.ContentType = "application/msword";//To Read Word Files
                Response.ContentType = "application/pdf";//To Read Pdf Files
                Response.AddHeader("content-length", buffer.Length.ToString());
                Response.BinaryWrite(buffer);
            }

No comments:

Post a Comment