473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Display a pdf stream in an ASP .NET page

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
Nov 19 '05 #1
9 12112
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.

Nov 19 '05 #2
If you combine the info from these two articles, you should be there:

http://support.microsoft.com/default...b;en-us;326502

http://support.microsoft.com/default...b;en-us;307603

"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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


Nov 19 '05 #3
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.
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
If you combine the info from these two articles, you should be there:

http://support.microsoft.com/default...b;en-us;326502

http://support.microsoft.com/default...b;en-us;307603

"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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

Nov 19 '05 #4
Yes, you need to get it into a MemoryStream rather than a FileStream.

"Alina" <a@a.com> wrote in message
news:Oa**************@TK2MSFTNGP14.phx.gbl...
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.
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
If you combine the info from these two articles, you should be there:

http://support.microsoft.com/default...b;en-us;326502

http://support.microsoft.com/default...b;en-us;307603

"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
> 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
>
>



Nov 19 '05 #5
Hello Alina,

You can write the byte array out via Response.BinaryWrite.

--
Matt Berther
http://www.mattberther.com
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.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in
message news:OG**************@TK2MSFTNGP12.phx.gbl...
If you combine the info from these two articles, you should be there:

http://support.microsoft.com/default...b;en-us;326502

http://support.microsoft.com/default...b;en-us;307603

"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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


Nov 19 '05 #6
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

Nov 19 '05 #7
> 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
Nov 19 '05 #8
Thank you. Your ideea was good.
Here is my solution:
Response.ContentType = "Application/pdf";

memStream.WriteTo(Response.OutputStream);

Response.Flush();

"Matt Berther" <mb******@hotmail.com> wrote in message
news:22***************************@news.microsoft. com...
Hello Alina,

You can write the byte array out via Response.BinaryWrite.

--
Matt Berther
http://www.mattberther.com
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.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in
message news:OG**************@TK2MSFTNGP12.phx.gbl...
If you combine the info from these two articles, you should be there:

http://support.microsoft.com/default...b;en-us;326502

http://support.microsoft.com/default...b;en-us;307603

"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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


Nov 19 '05 #9
You don't need to write the PDF to a file before outputting it.
You can grab any kind of a file from out of SQL Server and write it directly
to the output stream.
Here are the details:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"msnews.microsoft.com" <a@a.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kevin | last post by:
Hi all, Assuming I have stored the binary data of an image file in a blob field of a table, how can I display it as an image in a web page? I found some instructions on the web, such as ...
1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
1
by: Adam | last post by:
I am having difficulty retrieving images from a SQL database. Here is the code I use to UPLOAD the image to the database: <form id="Form1" method="post" enctype="multipart/form-data"...
1
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to...
6
by: Michel Rouzic | last post by:
With the following code : int main() { int i, j, n; n=12; for (i=0; i<n; i++) { printf("Iteration %i out of %i\n", i+1, n);
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
4
by: Jono | last post by:
Hi Everyone, As it says in the title, I'm looking for a way to display a page while long running operations are performed on the server. Ideally, I'd like some way to push the current request...
1
by: needin4mation | last post by:
Hi, using this code I pieced together from others: <%@ Page language="c#" Debug="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Drawing2D" %> <%@ Import...
2
by: * Tong * | last post by:
Hi, I'm wondering if you can show me an example php page that allows me to retrieve and display 3rd party pages. I.e., when my php script is called as http://site/path/getit.php?file_key it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.