View PDF Files using Acrobat in C#

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: design 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.
  1.  private void button2_Click(object sender, EventArgs e)
  2.         {
  3.            
  4.             openFileDialog1.Filter = "PDF Files (*)|*.pdf";
  5.  
  6.             if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  7.             {
  8.                 TextBox1.Text = openFileDialog1.FileName;
  9.             }
  10.         }
4. For Button1 as viewing of PDF files, put this code below.
  1.                 public void Button1_Click(System.Object sender, System.EventArgs e)
  2.                 {
  3.             // Instantiate a process named proc
  4.             //  processes enable to start and stop local system processes.
  5.                         Process proc = new Process();
  6.  
  7.             //filedirectory and filename
  8.                         proc.StartInfo.Arguments = TextBox1.Text;
  9.             // excecute the shell of the process to true
  10.                         proc.StartInfo.UseShellExecute = true;
  11.             // the processed program will be maximized
  12.                         proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
  13.             // directory to open for the process
  14.                         proc.StartInfo.WorkingDirectory = "C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\"; //<----- Set Acrobat Install Path
  15.                         //Set Acrobat Exe Name
  16.             proc.StartInfo.FileName = "AcroRd32.exe";
  17.                         // start process
  18.                         proc.Start();
  19.             //close the process
  20.                         proc.Close();
  21.             // dispose the process
  22.                         proc.Dispose();
  23.                 }
Output: output 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

Add new comment