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.
-
1Quite a broad question, don't you think?Oded– Oded2011-02-22 21:02:06 +00:00Commented Feb 22, 2011 at 21:02
-
PDF are actually loaded in browser using browser plugins. Are you looking for a control that parses the PDF in the server side and load the content inside an IFrame, may be ?abhishek– abhishek2011-02-22 21:03:09 +00:00Commented Feb 22, 2011 at 21:03
-
2Could look in to using Google Docs. Pass the PDF to google and have it to the PDF->HTML for you, though this is hacky at-best. PDFs exist for portability, I don't see why your client wouldn't have support for one of the most versatile document formats around.Brad Christie– Brad Christie2011-02-22 21:04:20 +00:00Commented Feb 22, 2011 at 21:04
-
@Oded- Absolutely. Its a broad problem.MAW74656– MAW746562011-02-22 21:28:33 +00:00Commented Feb 22, 2011 at 21:28
-
@Brad Christie- Yes, PDFs stand for portable document format, but I need to be able to display the pdf's in a browser with database information displayed as well. If I can easily embed a viewer into my asp.net page, I would consider that an option.MAW74656– MAW746562011-02-22 21:29:58 +00:00Commented Feb 22, 2011 at 21:29
6 Answers
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.
Comments
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.
Comments
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?
4 Comments
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.
Comments
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
iframeand 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.