Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2006, 05:59 PM
Authorized User
 
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Show a pdf file on the page

Hi, I want to show a pdf on the page, but it always promts me to open or save the file, I'm using the following code:

Dim fs As FileStream
fs = New System.IO.FileStream("file.pdf", FileMode.Open, FileAccess.Read)
Dim Buffer(fs.Length) As Byte
fs.Read(Buffer, 0, CInt(fs.Length))
fs.Close()
Response.BufferOutput = True
Response.ClearContent()
Response.ClearHeaders()
Response.AddHeader("Content-Length", Buffer.Length.ToString)
Response.AddHeader("content-disposition", "inline")
Response.ContentType = "application/pdf"
Response.BinaryWrite(Buffer)
Response.Flush()
Response.End()

What's wrong with that code, I'm using aspx 1.1 thanks for you help!!!

 
Old October 5th, 2006, 04:56 PM
Authorized User
 
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I realized that the code works well in some client browsers, I tested in some clients (all of them IE over win xp) In some cases the pdf displays in the page, but in other cases it prompts to save or open, I don't know why

 
Old October 5th, 2006, 05:17 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Dont know how i missed this post but your right, it all depends on the browser and how it handles the binary stream when a pdf is coming down the pipe.



--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
open pdf file within aspx page shaktis General .NET 3 November 2nd, 2007 12:58 PM
converting web page to pdf file swati_joshi ASP.NET 1.0 and 1.1 Professional 5 September 19th, 2006 07:58 AM
Access report print each page to separate PDF file conh2so4aq Access VBA 5 July 3rd, 2006 08:00 PM
upload doc,pdf file from ORACLE 9i on JSP page ashwinmittal Pro JSP 1 November 30th, 2004 01:18 PM
Show PDF without a webpage?? morpheus Classic ASP Basics 2 March 6th, 2004 09:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.