Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Byte[] with PDF, how to stream to client, anyone know ? need some help.

Reply
Thread Tools

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

 
 
jesper_lofgren@yahoo.se
Guest
Posts: n/a
 
      03-29-2007
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();

 
Reply With Quote
 
 
 
 
David
Guest
Posts: n/a
 
      03-29-2007
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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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();
>



 
Reply With Quote
 
 
 
 
Mythran
Guest
Posts: n/a
 
      03-29-2007


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
<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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Anyone know how to work with Xpath of Xmlnode ? need some help with this. jesper_lofgren@yahoo.se ASP .Net 1 04-04-2007 12:05 PM
LOOK! i just want to know does anyone know... Simon Egginton Javascript 3 07-26-2004 08:11 PM
I know, I know, I don't know Andries Perl Misc 3 04-23-2004 02:17 AM
I need some advice on 70-292 anyone know? gilberto MCSE 1 09-30-2003 11:48 PM



Advertisments