11

I'm wondering what's the best option to display a pdf/doc document inside form in my c# winforms app.

This control should only allow do display preview. Edtiting documents should be forbidden.

I'm looking for free solution.

The best option would be to attach a few separate *.dlls to solution but it's not a requirement.

tomo
  • 1,942
  • 2
  • 28
  • 43

4 Answers4

18

I wrote something that can do this for Word Documents by taking advantage of the WebBrowser control for WinForms. Hopefully it might do you some good:

http://codinglight.blogspot.com/2008/10/simple-docbrowser-control.html

techturtle
  • 2,479
  • 5
  • 26
  • 52
David Morton
  • 15,960
  • 2
  • 61
  • 72
  • I'd create a demo of it working and open-source it on github or something of that sort. This is a solid solution and you deserve more upvotes. – Lyuben Todorov Apr 15 '13 at 11:40
  • The original question was in response to someone who is familiar with .NET. I just don't see the use of explaining how to use the code. That wasn't the question. The question was how to display a document in C#, so that is what I answered. If it doesn't work for you, then feel free to down vote it, but explaining .net code and how to use it Is not part of this question. – David Morton Nov 08 '14 at 23:23
  • Does this also work for PDF files? Didn't see any mention of PDF in the code but since Word can save files as PDF so I wasn't sure... Just curious – fifamaniac04 Nov 23 '16 at 19:40
  • I would think you should be able to open the web browser with the URL pointing to the PDF file and it should natively work. Not sure though. This post is almost 8 years old. – David Morton Dec 02 '16 at 15:02
1

Consider using the preview handlers for Vista, Windows 7. I used the code provided by Brad Smith (with corrections from the comments).

http://www.brad-smith.info/blog/archives/79 - Hosting Preview Handlers in Windows Forms Applications

ptilton
  • 122
  • 3
  • 13
0

An often suggested solution is to use a webbrowser component inside the form that views the PDF: MSDN

Another approach is to use an ActiveX Control included with the Adobe Acrobat Reader but therefore you need a license from Adobe.

dajood
  • 3,618
  • 9
  • 43
  • 68
0

You can use Preview Handlers. There is a WPF Article over at CodeProject, which should be dead easy to translate to WinForms if you need it.

Jonathan C Dickinson
  • 7,053
  • 4
  • 34
  • 46