How to display a pdf file in asp.net web-form
I'm looking f开发者_开发问答or 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.
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.
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.
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?
There are flash apps available to do this. e.g. whatever http://issuu.com/ is using.
Even with converting PDF
to HTML
or IMAGE
you will not get the same quality or something near to the original document. It's more than bunch of texts and images with PDF
.
If your clients cannot support most famous document format (portable document format -> pdf), then you need to think about the design again.
You can do it by using this project which is based on Microsoft Silverlight framework.
In the mentioned project there are two cases:
- 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
- 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.
精彩评论