How to Show pdf file in C#

We know that PDF is not Microsoft technology, it is created by Adobe system and widely used for document exchange, and based on post script. .Net framework does not provide any library to handles PDF files or it is not easy to handle PDF files in .net.

If we want to show PDF file in .net windows form than we can use many approaches such as we can use web browser control or we can use office library. But except these we can also use Acrobat reader control. Adobe provides an ActiveX COM control that you can add to the C# Toolbox.  It is free component provided by Adobe Acrobat.

Start C# Windows application and add the ‘Adobe PDF Reader’ control to the C# Toolbox.
Right-click on any tab of toolbox and select “Choose Items…’ Select the “COM Components” tab and check “Adobe PDF Reader” and click OK.

display pdf file in the web browser

you can see Adobe PDF Reader control icon in toolbox than you can drag and drop this control on your form.

Adobe PDF Reader control in C#

Add a button control and write code to its click event.

private void button1_Click(object sender, EventArgs e)
{
  // Create object of Open file dialog clas
  {
     OpenFileDialog dlg = new OpenFileDialog();
     // set file filter of dialog
     dlg.Filter = "pdf files (*.pdf) |*.pdf;";
     dlg.ShowDialog();
     if (dlg.FileName!= null)
       {
         // use the LoadFile(ByVal fileName As String) function for open the pdf in control
          axAcroPDF1.LoadFile(dlg.FileName);
       }
   }
}

To use the Reader control, first make sure that you have downloaded and installed the free Acrobat Reader from Adobe.

You can download from here
http://get.adobe.com/reader/

If you want to more control on the Acrobat Reader control, you can use Adobe Acrobat SDK from their developer center (http://www.adobe.com/devnet/acrobat). And need to purchase from Adobe.