Byte[] with PDF, how to stream to client, anyone know ? need some help.

Discussion in 'ASP .Net' started by jesper_lofgren@yahoo.se, Mar 29, 2007.

  1. Guest

    Hello,

    I have a bytearray with a pdf document inside. I whant to stream it to
    the client (explorer IE) for download.
    I just got the bytes writen on the screen , like

    %PDF-1.4 %???? 10 0 obj<> endobj xref 10 1627 0000000016 00000 n
    0000035440 00000 n 0000032836 00000 n 0000035530 00000 n 0000035570
    00000 n 0000035748 00000 n 0000059461 00000 n 0000071166 00000 n
    0000083493 00000 n 0000096142 00000 n 0000109794 00000 n 0000125436
    00000 n 0000132712 00000 n 0000139138 00000 n 0000152636
    00000.........


    My Code !


    byte[] file = test.GetDocument("38GBRRHRA2QS8B7J");

    Response.Clear();
    Response.Buffer = false;

    Response.ContentType = "Application/pdf";

    Response.BinaryWrite(file);
    Response.Flush();
    , Mar 29, 2007
    #1
    1. Advertising

  2. David Guest

    Something you may not be aware of is that if you were testing to screen
    initially (i.e. not downloading), then change the code to download, your
    download will still send to screen.

    To get around this, you need to change your web address slightly. Just put a
    ? after the end of the address (or if you already have a ?, put an &)

    This will ensure you are not getting it from cache. If you then use it
    again, you might get the same issue, so what I usually do is something like
    ?test=1 then ?test=2 to ensure a clean address.

    Hope this helps...

    --
    Best regards,
    Dave Colliver.
    http://www.AshfieldFOCUS.com
    ~~
    http://www.FOCUSPortals.com - Local franchises available


    <> wrote in message
    news:...
    > Hello,
    >
    > I have a bytearray with a pdf document inside. I whant to stream it to
    > the client (explorer IE) for download.
    > I just got the bytes writen on the screen , like
    >
    > %PDF-1.4 %???? 10 0 obj<> endobj xref 10 1627 0000000016 00000 n
    > 0000035440 00000 n 0000032836 00000 n 0000035530 00000 n 0000035570
    > 00000 n 0000035748 00000 n 0000059461 00000 n 0000071166 00000 n
    > 0000083493 00000 n 0000096142 00000 n 0000109794 00000 n 0000125436
    > 00000 n 0000132712 00000 n 0000139138 00000 n 0000152636
    > 00000.........
    >
    >
    > My Code !
    >
    >
    > byte[] file = test.GetDocument("38GBRRHRA2QS8B7J");
    >
    > Response.Clear();
    > Response.Buffer = false;
    >
    > Response.ContentType = "Application/pdf";
    >
    > Response.BinaryWrite(file);
    > Response.Flush();
    >
    David, Mar 29, 2007
    #2
    1. Advertising

  3. Mythran Guest

    <> wrote in message
    news:...
    <snip>
    > My Code !
    >
    >
    > byte[] file = test.GetDocument("38GBRRHRA2QS8B7J");
    >
    > Response.Clear();
    > Response.Buffer = false;
    >
    > Response.ContentType = "Application/pdf";
    >
    > Response.BinaryWrite(file);
    > Response.Flush();
    ></snip>


    byte[] file = ...;

    Response.AppendHeader("Content-Length", file.Length.ToString());
    Response.AppendHeader("Content-Disposition",
    "inline;filename=filename.pdf");
    Response.ContentType = "Application/pdf";
    Response.ClearContent();
    Response.BufferOutput = true;

    Response.BinaryWrite(file);
    Response.Flush();
    Response.End();


    HTH,
    Mythran
    Mythran, Mar 29, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deep
    Replies:
    6
    Views:
    473
    Nick Keighley
    Feb 28, 2007
  2. dolphin
    Replies:
    6
    Views:
    545
    Thomas Fritsch
    Mar 18, 2007
  3. Replies:
    1
    Views:
    379
    Alexey Smirnov
    Apr 4, 2007
  4. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    222
    Gregory Toomey
    Apr 23, 2004
  5. Roedy Green

    byte stream vs char stream buffer

    Roedy Green, May 7, 2014, in forum: Java
    Replies:
    20
    Views:
    164
    Silvio
    May 18, 2014
Loading...

Share This Page