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

J

jesper_lofgren

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();
 
D

David

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
 
M

Mythran

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top