Response.BinaryWrite problem

Results 1 to 2 of 2

Thread: Response.BinaryWrite problem

  1. #1
    Join Date
    Dec 1969

    Default Response.BinaryWrite problem

    Hi,<BR><BR>I have the following code which is *supposed* to write out a pdf document to the browser but which writes out garbage instead:<BR><BR>dim objStream<BR>set objStream = server.CreateObject("ADODB.Stream")<BR>objStream.T ype = 1<BR>objStream.Open<BR>objStream.LoadFromFile("e:/pdfs/somepdf.pdf")<BR>Response.Clear<BR>Response.Conten tType="application/pdf"<BR>Response.AddHeader "content-disposition", "attachment; filename=somepdf.pdf"<BR>Response.AddHeader "content-disposition", "inline; filename=somepdf.pdf"<BR>Response.BinaryWrite objStream.Read<BR>ObjStream.Close<BR>set objStream=nothing<BR>Response.End<BR><BR><BR>Pleas e help because I&#039;ve been pulling my hair out over this one!<BR><BR>Thanks in advance,<BR>Conor.

  2. #2
    Join Date
    Dec 1969

    Default RE: Response.BinaryWrite problem

    Your code does work but you&#039;re not calling it correctly. You can&#039;t just execute this file on it&#039;s own, it needs to be called from another page as you would call a pdf file. So call this file "getpdf.asp" or something like that. You can even pass the page attributes and dynamically build the loadfromfile line so you can get any pdf you want just by changing the arguments. Then call it from your other page as you would call a pdf file:<BR><BR>&#060;a href="getpdf.asp"&#062;MypdfLink&#060;/a&#062;<BR><BR>Also, remove one of your AddHeader statements, either use attachment or inline. I believe your second statement is just replacing the first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts