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. The .Net framework does not provide a library to easily handle PDF files in .Net. If we want to show a PDF file in a .Net form then we can use many approaches such as we can use webbrowser or we can use office library, but we can also use the Acrobat Reader control. Adobe provides an ActiveX COM control that you can add to the CSharp Toolbox.  It is a free Adobe Acrobat PDF Reader.

Start C# Windows application and add the control to the C# Toolbox.

Right-click on any tab of toolbox and select "Choose Items... Select the "COM Components" tab and click the check "Adobe PDF Reader" and click OK.

COM Components

You will see the Adobe PDF Reader control icon in the toolbox, then you can drag and drop this control onto your form.

2.jpg

And add a button and add code to its click event for opening PDF files.

  1. private void button1_Click(object sender, EventArgs e)  
  2. {  
  3.     // Create object of Open file dialog class  
  4.     {  
  5.         OpenFileDialog dlg = new OpenFileDialog();  
  6.         // set file filter of dialog   
  7.         dlg.Filter = "pdf files (*.pdf) |*.pdf;";  
  8.         dlg.ShowDialog();  
  9.         if (dlg.FileName != null)  
  10.         {  
  11.             // use the LoadFile(ByVal fileName As String) function for open the pdf in control  
  12.             axAcroPDF1.LoadFile(dlg.FileName);  
  13.         }  
  14.     }  
  15. }  
To use the Reader control, first make sure that you have downloaded and installed the free Acrobat Reader from Adobe.
 
You can download it from here
 
 
If you want to control the Reader, you can use Adobe Acrobat SDK from their developer center (https://www.adobe.com/devnet/acrobat.html) and need to purchase from Adobe