How to display a pdf file in asp.net web-form

15,555

Solution 1

http://www.beansoftware.com/ASP.NET-Tutorials/PDF-View-Custom-Control.aspx

Did what I was looking for. A control that can display a pdf in the browser on a web form, with other elements on the page, and whose pdf file source can be changed by server-side code.

Solution 2

I think you might look into this :

how to convert PDF into HTML using C#

The code will help you load the PDF as html in your document.

Solution 3

You can do it by using this project which is based on Microsoft Silverlight framework.

In the mentioned project there are two cases:

  1. Blend Visually - used to output a PDF in
  • Create the positioning div
  • Create iframe and position/size it
  • Calling mqzJsCalls.moveHTMLZone(x,y,w,h) from the Silverlight User Control
  • Load PDF into iframe
  1. Data exchange between Silverlight and PDF (input/output from/to PDF)
  • Setting up the message handler and the hostContainer
  • Expose scriptable object from managed code
  • PDF notifies the host that it's ready
  • Host sends data to PDF
  • Host notifies the PDF it needs user data
  • PDF sends the user data to the host

I did not personally tested this particular project but I found this site good and reliable for .NET solutions.

Solution 4

If you don't want to display as PDF on the client, you have some options... Basically, most of your options revolve around converting the documenting to something else the user can use:

  • HTML
  • RTF (most people can view / print that with client software)
  • You could always use software to convert that to a set of images, but this is pretty processor intensive and would require the user to print these out invidually.
  • Convert to xps, but that would require that xps be installed on the client's machines.

So why can't you rely on a PDF viewer?

Share:
15,555
MAW74656
Author by

MAW74656

Updated on July 18, 2022

Comments

  • MAW74656
    MAW74656 almost 2 years

    I'm looking for a free way or .Net component to display PDF files in the browser and allow for printing of the files also. What methods/components/libraries can do this, and what guidance do you have on the problem in general.