Is there any way to view PDF files in a Winforms tool? I've seen solutions such as converting the pdf file into images and showing them in an picture box. However, I am asking whether i can view the file as PDF. Is there any tool from adobe or from Microsoft that supports this?
Asked
Active
Viewed 1.4e+01k times
42
-
2Not all end-user computers will have Adobe Reader or some other PDF viewer (with a IE plugin) installed. So, you will need a native .NET control to display the PDF. Gnostice has a [PDF viewer control for .NET](http://www.gnostice.com/nl_article.asp?id=159&t=How_To_Create_A_PDF_Viewer_in_PDFOne_NET_v2_x "PDF viewer control for .NET") in the PDFOne component suite. Disclaimer: I work for this company. – BZ1 Jan 05 '11 at 08:48
-
interesting!! i already finished the project i was working on when i asked this question .. but i'm gonna try this for sure!! thx for the tip ;) – Majd Jan 07 '11 at 23:25
-
This was answered in an WPF question so I don't know if it works, but it is for winforms... http://stackoverflow.com/questions/55083/opening-a-pdf-in-wpf-application/55177#55177 – LD7 Dec 21 '10 at 22:17
5 Answers
31
i think the easiest way is to use the Adobe PDF reader COM Component
- right click on your toolbox & select "Choose Items"
- Select the "COM Components" tab
- Select "Adobe PDF Reader" then click ok
- Drag & Drop the control on your form & modify the "src" Property to the PDF files you want to read
i hope this helps

Saif al Harthi
- 2,948
- 1
- 21
- 26
-
how can i resize this control so that it does not consume the whole form but stil resize when the form resizes? – thewikus Nov 21 '13 at 10:21
-
-
1I have this com component on my development machine. Does it also work on machines that do not have Adobe installed? – Stephan Stamm Feb 15 '19 at 12:10
-
1It will not work on a machine that does not have Adobe PDF Reader installed. You will get "Class not Registered" exception. Related Post: https://stackoverflow.com/questions/4041659/comexception-0x80040154-class-not-registered-when-using-axacropdflib/17894788 – Senthi Sri Jun 25 '21 at 18:41
31
you can use System.Diagnostics.Process.Start as well as WIN32 ShellExecute function by means of interop, for opening PDF files using the default viewer:
System.Diagnostics.Process.Start("SOMEAPP.EXE","Path/SomeFile.Ext");
[System.Runtime.InteropServices.DllImport("shell32. dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters,
string lpDirectory, long nShowCmd);
Another approach is to place a WebBrowser Control into your Form and then use the Navigate method for opening the PDF file:
ThewebBrowserControl.Navigate(@"c:\the_file.pdf");

ArBR
- 4,032
- 2
- 23
- 29
-
8no he wants the windows form project he's doing hosting the reader , not launch it – Saif al Harthi Dec 21 '10 at 22:26
-
1Yes, as Saif said, I need to view the pdf file inside my application and not launch the PDF reader :) – Majd Dec 21 '10 at 22:36
-
1
-
-
Did you able to show the pdf inside WebBrowser Control ? I am trying the same thing but the application doesn't open it inside control rather it launces the third party PDF viewer application to show the pdf. – Soumyaansh Nov 30 '16 at 11:22
-
2@Soumyaansh were you able to fix the issue.As, I am facing the same problem. – V K Feb 09 '17 at 08:46
3
Web Browser control might work. http://ryanfarley.com/blog/archive/2004/12/23/1330.aspx
Also a bunch of pdf open source c# projects here http://csharp-source.net/open-source/pdf-libraries

madmik3
- 6,975
- 3
- 38
- 60
0
http://www.youtube.com/watch?v=a59LvC6BOuk
Use the above link
private void btnopen_Click(object sender, EventArgs e){
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK){
axAcroPDF1.src = openFileDialog1.FileName;
}
}

joakimbl
- 18,081
- 5
- 54
- 53

Gokuldas.Palapatta
- 72
- 8