Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[2235] Send Binary Data from ASP

Last post 02-12-2006 2:21 AM by ckchan. 45 replies.
Page 3 of 4 (46 items) < Previous 1 2 3 4 Next >
Sort Posts: Previous Next
  • 05-09-2003 10:18 AM In reply to

    still not working

    Sorry to be stupid :-)
    But i still have problems
    I heve the code here after
    The aim is to retrieve a dynamically generated PDF from another server by submitting a POST with the params.
    The the result od this post, the PDF stream should be sent to the client browser.
    if I do a response.BinaryWrite strValue,  or a response.Write, i get this error message
    'An unhandled data type was encountered.'
    If a don't use a write but only have a look at the result I get
    'status : 200statustext : OK ' so looks ok Here is the code

    xmlhttp.send "TYPEDOC=STREAM"
    strValue = xmlhttp.responseStream
    'response.write "number of chars " & len(strValue) & "<br>"
    response.write "status : "  & xmlhttp.status
    response.write "statustext : "  & xmlhttp.statustext
    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 06-27-2003 9:14 AM In reply to

    • kendeyo
    • Not Ranked
    • Joined on 06-27-2003
    • New Member
    • Points 5
    I am having the same problem where it wants to save the asp file, not the pdf file.  ???
    Does anyone know why this is?

    Quote:
    [1]Posted by acuze104 on 16 Dec 2002 06:31 PM[/1]
    I'm having the same exact problem.. " dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file. "   I need help with this ASAP...  


    I"m using a third party software called "activepdf toolkit" to create the pdf and put it in memory.  After it is done creating, i use this code  to display the pdf to the browser.


    response.ContentType = "application/pdf"
    response.AddHeader "Content-Type", "application/pdf"
    response.addHeader "Content-Disposition", "filename=part"&hour(Now)&""&minute(Now)&".PDF"

    This works fine in IE 5.0 and above for windows.. but not on the mac version.  


    Thanks in advance..
    • Post Points: 0
  • 06-02-2004 2:31 PM In reply to

    This is a really bad function if you are sending files that are large, or where speed matters. For instance, I tested this function on a managed server where I received a download rate of around 4k per second. However, if I browsed directly to the file instead of having the function pass it to me I achieve speeds of around 80 to 100k per second. That is a considerable slowdown and it is very inneficient to send binary data one byte at a time
    • Post Points: 0
  • 07-13-2004 8:47 AM In reply to

    • cboy
    • Not Ranked
    • Joined on 07-13-2004
    • New Member
    • Points 15
    I have same code and it doesn't work. White  screen appear instead of PDF document :-(
    • Post Points: 0
  • 07-13-2004 8:47 AM In reply to

    • cboy
    • Not Ranked
    • Joined on 07-13-2004
    • New Member
    • Points 15
    I have same code and it doesn't work. White  screen appear instead of PDF document :-(
    • Post Points: 0
  • 07-13-2004 4:25 PM In reply to

    White screen appear instead of PDF document

    cboy, if you have Adobe Reader 6 on your system the browser plugin sometimes get screwed, re-run the install of Adobe Reader and try again, it should be fine.
    -victor
    • Post Points: 0
  • 07-14-2004 12:12 AM In reply to

    • cboy
    • Not Ranked
    • Joined on 07-13-2004
    • New Member
    • Points 15
    I've discovered strange thing, that this code doesn't work only on
    machine where Visual Studio .NET 2005 (Whidbey) is installed.
    I check it on several computers and it is true.
    When I remove VS2005 and install only .NET-2.0,
    which is supplied whith VS 2005. Everything goes well.

    I use VS2005 alpha version which is little bit raw and has bugs
    • Post Points: 0
  • 01-05-2005 2:36 AM In reply to

    I have extra data in my pdf files so it doesn't wo

    I've created a database in Access 2000 and inserted my pdf files as OLE objects from within the database table view but when I get them out I have problems.

    It seems as my files have extra information at the head of them. From what I gather a pdf file's binary data should start with '%PDF-'  but the first couple of lines of mine seem to be as shown below. Is this an additional header or something that needs to be removed? (I got this data simply by removing the content type so that the binary data would be written as text).

    The code works fine on the original file but not when I get it from the database.
    Code:

       Dim EAMS_Database
       Set EAMS_Database = Server.CreateObject("ADODB.connection")
       EAMS_Database.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\Inetpub\wwwroot\db.mdb")
       Set objRS = EAMS_Database.Execute("select pdf_object from articles where EntryId=1")
       Response.Buffer = True
       Response.Clear
       Response.ContentType = "application/pdf"  
       Response.BinaryWrite objRS(0)
       Response.end

       EAMS_Database.Close


    Any ideas?

    Code:
    7%ÿÿÿÿAcrobat DocumentAcroExch.DocumentAcroExch.DocumentÔÐÏࡱá>þÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÿÿÿèþÿÿÿáýÿÿÿýÿÿÿýÿÿÿ  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€Root Entryÿÿÿÿÿÿÿÿeʸü¡Ð…­DESTУƒóÄOle ÿÿÿÿÿÿÿÿÿÿÿÿContentsÿÿÿÿ ²OlePres000ÿÿÿÿÿÿÿÿPþÿÿÿ  !"#$%&'()*+,-./0123456789:þÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ«‹Lp4õ—XäÂzÈÈr“DÅ„öó~9šÇ¤]Ë;Ci’F7¿®êoÿÿÿÿÿÿÿÿì  ! `’  ÿÿÿ¥A ƈ 9( @ÿÿÿ ¥9II3ò%9999444449999-]IŸ%49494444999-]Ÿ%%%%%%%%%%%%%%%$ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ?ÿÿÿ!A Ff ‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàþÿÿÿâãäåæçþÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ%PDF-1.4 %âãÏÓ 143 0 obj<>stream xÚ¬WKoÛFæßèm_âƒÁ}?‚ €,hàØM$9(>°2! uDƒ’ûÏ·ývWÑ‹JEE>Ãݝï›gv—B#!‰3A’“✤ åIIÚx’ŠŒ°$-¯H:²J’ôä”&ÅÈs y‘‹•„uÎ5¸q!Àä¶kuŒ¾X~ƒKâN¿ÝUx~/‹ÛÉt U‚6¦·‘ÉÊš¹ªç¼zÊ;÷óWá0xMÎ8u&5]U—ßPh”®RC†mÓôï ”s 9 Fíš·êG±_u{xÞ_ +•¤Fû©9¯nŸáxpdÖÒBc ¡­E&û5
    • Post Points: 0
  • 03-17-2005 4:00 AM In reply to

    • artwise
    • Not Ranked
    • Joined on 03-17-2005
    • New Member
    • Points 10

    Output Word?

    Is it possible to output the content of the file in the browser instead of pushing
    the file for downloading?

    Thanks
    • Post Points: 0
  • 05-20-2005 9:28 PM In reply to

    • lbarlean
    • Not Ranked
    • Joined on 05-20-2005
    • New Member
    • Points 5
    This worked for me....

    Response.ContentType = "application/msword"
    Response.OutputStream.Write(buffer, 0, buffer.length)....where buffer is a byte array.
    Don't add a Response.AddHeader
    Make sure the checkbox "Always ask before opening this type of file" in a download dialog isn't clicked.
    • Post Points: 0
  • 10-05-2005 2:12 PM In reply to

    pdf file doesn't open in IE

    hi
    i tried the followin code in a page using vb
    Dim tFileName
           tFileName = "1.pdf"
           Response.Clear
       Response.Buffer = True
       'Response.AddHeader "Content-Disposition", "attachment; filename=" & tFileName
       Response.ContentType = "application/pdf"
       Response.BinaryWrite(tFileName)

    but it throws error invalid cast
    • Post Points: 0
  • 10-05-2005 5:43 PM In reply to

    rocko_hunk, sure it will throw an error on this line: Response.BinaryWrite(tFileName)
    Because, tFileName is a string and you need to pass to Response.BinaryWrite method a binary array with proper PDF document.

    In VS2003 I have the following code that works w/o problems:

      Response.Clear();
      Response.Buffer = true;
      Response.ContentType = "application/pdf";
      Response.BinaryWrite(tPDF);
      Response.End();

    Where tPDF is a binary array that contains a PDF document.
    • Post Points: 0
  • 10-06-2005 7:05 AM In reply to

    pdf content into an array

    hi below is the code u sent

    Response.Clear();
     Response.Buffer = true;
     Response.ContentType = "application/pdf";
     Response.BinaryWrite(tPDF);
     Response.End();

    I know very well that I need to tPDF the content of pdf

    can you please tell me how to store the content of the (let us say a1.pdf) pdf file in an array
    so that i could pass it to the Response.BinaryWrite() method
    • Post Points: 0
  • 10-08-2005 7:39 PM In reply to

    • gjohnson
    • Not Ranked
    • Joined on 10-08-2005
    • New Member
    • Points 5

    Opening PDF in Windows 2000

    I am having the exact same problem except my code works on a Windows XP computer but does not work in Windows 2000.  In XP, acrobat opens in my web application and the pdf displays as it should.  In 2000 using the exact same code, I get the "file download" message box.  If I open the file, it opens as an aspx file showing the code that would have been used to generate the pdf.  In fact, if I change the extension of the aspx file to pdf, it will open as it should in acrobat.  Here is my code.  Must be a bug in Windows or IE?

    // Generate Crystal Report in PDF Format
    ContainerContents Report = new ContainerContents();
    Report.SetDataSource(ds);
    CrystalDecisions.Shared.ExportOptions RptExportOptions =
       new CrystalDecisions.Shared.ExportOptions();
    RptExportOptions.ExportFormatType =
       CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
    CrystalDecisions.Shared.ExportRequestContext RptExportRequestContext =
       new CrystalDecisions.Shared.ExportRequestContext();
    RptExportRequestContext.ExportInfo = RptExportOptions;
    System.IO.Stream RptStream = null;
    RptStream = Report.FormatEngine.ExportToStream(RptExportRequestContext);
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = @"application/pdf";
    Byte[] RptBuffer = new Byte[RptStream.Length];
    RptStream.Read(RptBuffer, 0, (int)RptStream.Length);
    Response.BinaryWrite(RptBuffer);
    Response.End();
    • Post Points: 0
  • 10-10-2005 4:01 PM In reply to

    RE:Opening PDF in Windows 2000

    gjohnson, I can think of two things.
    1. check XP/IE security settings
    2. Reinstall Adobe Reader.
    • Post Points: 0
Page 3 of 4 (46 items) < Previous 1 2 3 4 Next >