Viewing PDF in Windows forms using C#
Solution 1
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");
Solution 2
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
Solution 3
display PDF file into WinForms
Displaying a pdf file from Winform.
displaying a pdf on a windows form?
How to display PDF or Word's DOC/DOCX inside WinForms window?
Reading/Writing PDF Files in Visual C# Windows Forms
Solution 4
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
Majd
Updated on July 09, 2022Comments
-
Majd almost 2 years
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?
-
Paul Sasik over 13 yearsJust for viewing the IE browser control should work just fine.
-
Saif al Harthi over 13 yearsno he wants the windows form project he's doing hosting the reader , not launch it
-
Majd over 13 yearsYes, as Saif said, I need to view the pdf file inside my application and not launch the PDF reader :)
-
ArBR over 13 yearsUse the WebBrowser Control into your form.
-
Majd over 13 yearsyes i think i'll go with that .. thx ..
-
thewikus over 10 yearshow can i resize this control so that it does not consume the whole form but stil resize when the form resizes?
-
Soumyaansh over 7 yearsDid 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.
-
V K over 7 years@Soumyaansh were you able to fix the issue.As, I am facing the same problem.
-
Haseeb over 5 years1+ perfect this supposed to be answer :)
-
Stephan Stamm over 5 yearsI have this com component on my development machine. Does it also work on machines that do not have Adobe installed?
-
Senthi Sri about 3 yearsIt will not work on a machine that does not have Adobe PDF Reader installed. You will get "Class not Registered" exception. Related Post: stackoverflow.com/questions/4041659/…