Open a PDF file
-
Hello All! I'm working in VS 2005/VB.NET. There seems to be alot of ways to this. I'm just looking to open up a pdf file from a server. I don't have to modify or save it. I just need to view it in the web page. Can somebody show me or point me to a quick of doing this. Thanks! Rudy
-
Hello All! I'm working in VS 2005/VB.NET. There seems to be alot of ways to this. I'm just looking to open up a pdf file from a server. I don't have to modify or save it. I just need to view it in the web page. Can somebody show me or point me to a quick of doing this. Thanks! Rudy
-
if you are doing it server side code use response.redirect(pathWithFilename.pdf) and on clicent you can just give a link/button and open the pdf file like a href='http:\\url\file.pdf'
-----
-
Hello Sabhatti! Thank you for the quick response. That worked great, but I didn't realize it would open adobe. Is there a way to open a pdf file, while still in the webpage? Thanks! Rudy
hi you can try this : convert the file into byte array,set the Response.ContentType to application/pdf and do a binary write Sample code: string filePath=Request.MapPath("a.pdf"); System.IO.FileInfo ofile=new FileInfo(filePath); System.IO.FileStream fs = ofile.OpenRead(); int filelen=(int)fs.Length; byte[] b=new byte[filelen]; fs.Read(b,0,filelen); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType="application/pdf"; Response.BinaryWrite(b); Response.End(); Response.Flush();
-
hi you can try this : convert the file into byte array,set the Response.ContentType to application/pdf and do a binary write Sample code: string filePath=Request.MapPath("a.pdf"); System.IO.FileInfo ofile=new FileInfo(filePath); System.IO.FileStream fs = ofile.OpenRead(); int filelen=(int)fs.Length; byte[] b=new byte[filelen]; fs.Read(b,0,filelen); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType="application/pdf"; Response.BinaryWrite(b); Response.End(); Response.Flush();
-
hi you can try this : convert the file into byte array,set the Response.ContentType to application/pdf and do a binary write Sample code: string filePath=Request.MapPath("a.pdf"); System.IO.FileInfo ofile=new FileInfo(filePath); System.IO.FileStream fs = ofile.OpenRead(); int filelen=(int)fs.Length; byte[] b=new byte[filelen]; fs.Read(b,0,filelen); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType="application/pdf"; Response.BinaryWrite(b); Response.End(); Response.Flush();