Display a pdf stream in an ASP .NET page

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

Hello

I have a .pdf (from a SQL DB field) and I wish to display it in a ASP.NET
page (with the Adobe toolbar, or at least a print button..)

Thank you
 
C

charlie

The easiest way to do this (off the top of my head) is to take the
binary stream and write to a temp file with a .pdf file extenstion.
Then stream the file to the browser and let the browser display it to
the user using the Adobe client. You can delete the file after you
stream it so you don't junk up your server with a buch of temp files.
That may not be what you want to do but it would work and isn't that
difficult to do.
 
A

Alina

Thank you for your answer. My problem is that I don't wish to save the file.
I need to display the .pdf from memory directly into the Web page.
 
K

Ken Cox [Microsoft MVP]

Yes, you need to get it into a MemoryStream rather than a FileStream.
 
C

charlie

What Ken has given you is what we do. Good luck getting it to display
without saving the file - we could never get it to work properly
without doing that. The files only have to be there long enogh to
stream to the requestor. Maybe someone else has been successful
streaming the binary data without saving it?

c
 
D

darrel

Thank you for your answer. My problem is that I don't wish to save the
file.
I need to display the .pdf from memory directly into the Web page.

PDF's are pretty much stand-alone documents. You don't embed them within a
parent HTML page...you just link to them like you would a Word Document.
Google turns up a few hits on using the Embed or Object tags to embed it,
but the results appear to be pretty inconcistent.

You could consider using Macromedia flashpaper instead, which can take a PDF
and convert it into the Flash format, which can then be embedded on a page.

-Darrel
 
A

Alina

Thank you. Your ideea was good.
Here is my solution:
Response.ContentType = "Application/pdf";

memStream.WriteTo(Response.OutputStream);

Response.Flush();
 
Joined
Apr 15, 2010
Messages
1
Reaction score
0
Alina said:
Thank you. Your ideea was good.
Here is my solution:
Response.ContentType = "Application/pdf";

memStream.WriteTo(Response.OutputStream);

Response.Flush();


WOW! That's awesome material. So simple and so effective. Thanx for the post. I used it and it worked amazingly!
:star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star: :star:
 
Joined
Oct 12, 2010
Messages
1
Reaction score
0
display PDF documents in a webpage

There are various approaches used to display PDF documents in a webpage. Displaying PDF documents in a webpage using simple ASP.NET custom server control or Directly rendering the PDF documents on the webpage. So if you want to know more details on these approaches, you can refer below.

protalk.in/dotnet/how-to-display-pdf-documents-with-asp-net-part-1/

protalk.in/dotnet/how-to-display-pdf-documents-with-asp-net-part-2/
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top