Link to home
Start Free TrialLog in
Avatar of tranqy
tranqy

asked on

binarywrite with PDF problem

I am trying to binarywrite a PDF file to the browser.  No matter what I try, I just get the binary data in the browser, instead of acrobat opening.  Please look at this code and tell me if you can find any problems.  Thanks..

---- ASP
     Set objBinFile = Server.CreateObject("ASPBinFile.clsASPBinFile")
     mFile = rsinvoice("filename")
     mStream = objBinFile.BinFileRead(mFile)
     response.buffer=true
'      Response.CacheControl = "public"
'     response.expires = 0
     Response.contenttype = "application/pdf"
     Response.AddHeader "Content-Disposition", "inline;filename=invoice.pdf"
'     Response.Addheader "Content-Length", LenB(mstream)
     Response.binarywrite mstream
     response.end()
     response.flush
     Set objBinFile = Nothing
else
     response.write "DOH!"
end if

---- objBinFile.BinFileRead()
Option Explicit


Function BinFileRead(ByVal inFileSpec As String) As Variant
     On Error GoTo errHandler
     Dim mHandle
     Dim lngFileLen As Long
     Dim arrData() As Byte
       
     mHandle = FreeFile
     Open inFileSpec For Binary Access Read As #mHandle

     lngFileLen = FileLen(inFileSpec)
     ReDim arrData(lngFileLen)

     Get #mHandle, , arrData
     Close #mHandle
       
     BinFileRead = arrData
     Exit Function

errHandler:
End Function
ASKER CERTIFIED SOLUTION
Avatar of Chesty
Chesty

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
Avatar of tranqy
tranqy

ASKER

I worked with this page forever, and all I had to do was pull out the html tags.  ARGH.  Thank you very much for your insight.  Your answer fixed my problem!