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.
you can see Adobe PDF Reader control icon in toolbox than you can drag and drop this control on your form.
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.
Hi………
Its really nice. You are giving this code for opening AxAcroPDF but now i want to save that opened .pdf file into sql server2008.
Please help me. It’s urgent. I am waiting for your reply….
Please send me code on dimple.gulame@gmail.com.
Thanks in advance……….
That is very nice tutorial….Thanks a lot Mr…
hey,
I think (dlg.Filter = “pdf files (*.pdf) |*.pdf;”;)
line should be corrected like this…
(dlg.Filter = “all files|*.pdf”;) or should be removed that bracket…
Thanks a lot man for provinding this code…
the code helps me a lot to solve my problem in my application…:) 🙂
What version of VS are you using. I’ve tried this with VS2005 & VS2010 with Reader X & XI respectively. The DLL isn’t there. Are you sure you don’t need the full Acrobat installed?
The only Acrobat reader should installed on the machine..
You can verify whether your machine has the DLL or not from the :
C:Program Files (x86)Common FilesAdobeAcrobatActiveXAcroPDF.dll
see attached image.