View PDF Files using Acrobat in C#
Submitted by donbermoy on Saturday, June 21, 2014 - 08:26.
In this tutorial, I will teach you how to create a program that will view PDF files using C#.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application and name your project as Open Acrobat PDF Reader.
2. Next, add only two Buttons named Button1 and labeled it as "Open PDF File" and Button2 for browsing PDF files. Insert a textbox named TextBox1 for inputting the file directory and file name of the pdf you wanted to view. You must design your interface like this:
3. For Button2 as browsing PDF files, put this code below. This will filter to open PDF files only and will add the file directory in the textbox1.
4. For Button1 as viewing of PDF files, put this code below.
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- private void button2_Click(object sender, EventArgs e)
- {
- openFileDialog1.Filter = "PDF Files (*)|*.pdf";
- if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- TextBox1.Text = openFileDialog1.FileName;
- }
- }
- public void Button1_Click(System.Object sender, System.EventArgs e)
- {
- // Instantiate a process named proc
- // processes enable to start and stop local system processes.
- //filedirectory and filename
- proc.StartInfo.Arguments = TextBox1.Text;
- // excecute the shell of the process to true
- proc.StartInfo.UseShellExecute = true;
- // the processed program will be maximized
- proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
- // directory to open for the process
- proc.StartInfo.WorkingDirectory = "C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\"; //<----- Set Acrobat Install Path
- //Set Acrobat Exe Name
- proc.StartInfo.FileName = "AcroRd32.exe";
- // start process
- proc.Start();
- //close the process
- proc.Close();
- // dispose the process
- proc.Dispose();
- }
Add new comment
- 127 views