tags:

views:

99

answers:

4

Hello,

Can anyone suggest me which is the best way of displaying a PDF document in an aspx page. I want users to use zoom functionality while viewing the pdf document.

Thanks in advance

+1  A: 

Just serve the PDF as a standard PDF.

Daniel A. White
Daniel, Thanks But I dont want to open it in a new window. I want it to show in some kind of viewer
acadia
You could do it in an iframe.
Daniel A. White
A: 

This, or these any help?

Edit - Thats assuming you want to embed otherwise as Daniel suggests, just serve it direct to the user.

Jammin
+1  A: 

If you have the PDF in memory use one of the Stream objects to break it down to a byte array (possibly using the .ToArray() function of the MemoryStream class). In this example below the byte array is called data:

Response.ContentType = "Application/pdf";

Response.OutputStream.Write(data, 0, data.Length);

Edit: This approach works well if all you want to do is serve up a PDF. After reading some of the comments I realized the question was more focused on showing a PDF inside a section of a webpage. Another alternative I have used is an embed tag that references a codefile function. In this case, if you have the PDF on a disk drive you can use

<embed id="Embed1" src='<%# pdfLocation() %>' runat="server" name="pdfLoad"></embed>

Where the function pdfLocation returns a string representation of the location of the PDF file.

Justin C
I opt for this approach, setting the appropriate content type to force the browser to render the correct mime type.
Jay Zeng
thanks for the easy approach!!
eviljack
A: 

It looks like a Flash-based solution would work best for you in this situation, such as Adobe FlashPaper. There is no dependency on the browser having a PDF plug-in that displays the document in the browser, such as Adobe Reader or Foxit Reader. It supports zooming, searching, printing, full-screen mode, and text selection, and you don't have to rely on a third-party hosted solution like Scribd.

Tim S. Van Haren