Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - FSO to Display a PDF
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

FSO to Display a PDF

 Post Reply Post Reply
Author
Chattan View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Australia
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chattan Quote  Post ReplyReply Direct Link To This Post Topic: FSO to Display a PDF
    Posted: 24 November 2003 at 7:03pm

Hi I am trying to display a pdf that is in a browse disabled folder on my web server.

Using an FSO Text Stream I can display a text file that is located in the same folder but when I try the pdf it displays it but it doesnt recognise it as a pdf and tries to display text so you get jibberish.

Can anyone advise how to tell the FSO to display it as a PDF. 

Cheers Chattan

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 7:11pm

yeah, you can't...

PDF is not plain text, so FSO Text Stream won't show anything but the compiled "jibberish"

you'll have to use a DataStream to push it to the client.....

Contribute to the working anarchy we fondly call the Internet
Back to Top
Chattan View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Australia
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chattan Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 7:15pm
Thanks Ive been banging my head agains that one for two days.
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 7:26pm

just remember for down the road that the FSO Text stuff will read any file just like it was opened up in Notepad...

so jibberish in Notepad = jibberish to FSO.Text stuff

Contribute to the working anarchy we fondly call the Internet
Back to Top
Chattan View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Australia
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chattan Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 8:07pm

Ive only been playing with fso for the last week so its all new to me . I managed to get it to work using the following code.

<%
 Response.ContentType = "application/pdf"
 
 strFilePath = "c:/folder/file"
 
 Dim oStream
 Set oStream = Server.CreateObject("ADODB.Stream")

 oStream.Open
 oStream.Type = 1 'adTypeBinary
 
 oStream.LoadFromFile strFilePath
 
 varPdf = oStream.Read

 Response.BinaryWrite( varPdf )
 
 oStream.Close
 Set oStream = Nothing
%>

 

Know I just need to carry the link name into the fso so it knows which file to display that way I wont have to create a fso page for every indervidual pdf.

Thanks for your help.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 8:23pm
Originally posted by Chattan Chattan wrote:

Know I just need to carry the link name into the fso so it knows which file to display that way I wont have to create a fso page for every indervidual pdf.

is that a question or statement? lol

if its a question:

strFilePath = "c:\folder\file\" & Request.QueryString("FileName")

also might want to make sure the file exists, otherwise FSO will cough out an error

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists( strFilePath  ) Then
    oStream.LoadFromFile strFilePath
    varPdf = oStream.Read
    Response.BinaryWrite( varPdf )
Else
    'Some sort of error handling here
End If
Set FSO = Nothing

 

Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.