Display a pdf stream in an ASP .NET page

  • Thread starter Thread starter msnews.microsoft.com
  • Start date 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
 
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.
 
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.
 
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
 
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
 
Thank you. Your ideea was good.
Here is my solution:
Response.ContentType = "Application/pdf";

memStream.WriteTo(Response.OutputStream);

Response.Flush();
 

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

Back
Top