How to View PDF File inside the Form Using C#

In this tutorial, you will learn how to view PDF file inside the Form Using C#. PDF is the most commonly used by companies for their documents which includes images and text formatting. You have to install a PDF Reader first in your machine in order to add it in the Microsoft Visual Studio 2015. Just visit the official site of adobe acrobat. Here is the link https://get.adobe.com/reader/

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for c#. ps1

Step 2

Go to toolbars, right click and select choose items. ps2

Step 3

When the “Choose ToolBox Items” appear, go to COM Components and check Adobe PDF Reader then hit OK. ps3

Step 4

In the ToolBox, select PDF Reader, OpenFileDialog and a Button then drag it inside the form. Make the form just like shown below. ps5

Step 5

Double click a Button and add the following code to get a PDF File and to view it into the form.
  1.  
  2. OpenFileDialog ofd = new OpenFileDialog();
  3. ofd.Filter = "PDF |*.pdf";
  4. if(ofd.ShowDialog() == DialogResult.OK)
  5. {
  6. axAcroPDF1.src = ofd.FileName;
  7. }
The complete source code is included. You can download it and run it on your computer. For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT Or feel free to comment below.

Comments

Submitted byAbdulmk (not verified)on Tue, 07/02/2019 - 03:54

need the same topic but using pascal

Add new comment