Link to home
Start Free TrialLog in
Avatar of sp_wiz
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("Scripting.FileSystemObject")

      '-- check to see if the file exists
      If objFSO.FileExists(strAbsFile) 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(strAbsFile)
       
            '-- send the stream in the response
        Response.BinaryWrite(objStream.Read)
       
            objStream.Close
            Set objStream = Nothing
            
            Set objFile = Nothing
            
      Else  'objFSO.FileExists(strAbsFile)

            Response.Clear
            Response.Write("No such file exists.")

      End If

      Set objFSO = Nothing

End Sub
Avatar of pepsichris
pepsichris
Flag of United Kingdom of Great Britain and Northern Ireland image

Nothing seems out of place with your code.  

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?
ASKER CERTIFIED SOLUTION
Avatar of hammond_david
hammond_david

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial