2

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

acadia
  • 2,301
  • 10
  • 40
  • 57
  • http://stackoverflow.com/questions/291813/best-way-to-embed-pdf-in-html –  Dec 15 '09 at 14:30

4 Answers4

1

Just serve the PDF as a standard PDF.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
1

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
  • 1,924
  • 4
  • 28
  • 43
  • I opt for this approach, setting the appropriate content type to force the browser to render the correct mime type. – Jay Zeng Dec 15 '09 at 20:18
0

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
  • 8,861
  • 2
  • 30
  • 34
-1

This, or these any help?

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

Jammin
  • 3,050
  • 2
  • 23
  • 34