sp_wiz
asked on
ADODB.Stream Pdf's are corrupt on Windows 2000 Clients
This is a real strange one.
90% of all browsers and clients are fine, but some windows 2000 machines say that
the pdf is corrupt when opened from a browser.
Does anyone have any ideas on what is going on
Code is below
Sub DownloadFile(file, lstrName)
'--declare variables
Dim strAbsFile
Dim strFileExtension
Dim objFSO
Dim objFile
Dim objStream
'-- set absolute file location
strAbsFile = Server.MapPath(file)
'-- create FSO object to check if file exists and get properties
Set objFSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
'-- check to see if the file exists
If objFSO.FileExists(strAbsFi le) Then
Set objFile = objFSO.GetFile(strAbsFile)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" & lstrName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
Set objStream = Server.CreateObject("ADODB .Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(str AbsFile)
'-- send the stream in the response
Response.BinaryWrite(objSt ream.Read)
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
Else 'objFSO.FileExists(strAbsF ile)
Response.Clear
Response.Write("No such file exists.")
End If
Set objFSO = Nothing
End Sub
90% of all browsers and clients are fine, but some windows 2000 machines say that
the pdf is corrupt when opened from a browser.
Does anyone have any ideas on what is going on
Code is below
Sub DownloadFile(file, lstrName)
'--declare variables
Dim strAbsFile
Dim strFileExtension
Dim objFSO
Dim objFile
Dim objStream
'-- set absolute file location
strAbsFile = Server.MapPath(file)
'-- create FSO object to check if file exists and get properties
Set objFSO = Server.CreateObject("Scrip
'-- check to see if the file exists
If objFSO.FileExists(strAbsFi
Set objFile = objFSO.GetFile(strAbsFile)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" & lstrName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
Set objStream = Server.CreateObject("ADODB
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(str
'-- send the stream in the response
Response.BinaryWrite(objSt
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
Else 'objFSO.FileExists(strAbsF
Response.Clear
Response.Write("No such file exists.")
End If
Set objFSO = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It sounds like you're on a Network - any chance of there being a problem with the installation of Acrobat Reader on some of the 2000 PCs?