Windows Forms: How to Open and Show a PDF file in C#

How to open, show a PDF file in C# using Adobe Acrobat embed pdf to windows form

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "PdfViewer" and then click OK

pdf viewerStep 2: Design your form as below

c# pdf viewer

You need to install Adobe Acrobat Reader, then add a reference to Interop.AcroPDFLib, AxInterop.AcroPDFLib

Step 3: Add code to handle your form as below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PdfViewer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            using(OpenFileDialog ofd=new OpenFileDialog() { ValidateNames = true, Multiselect = false, Filter = "PDF|*.pdf" })
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    axAcroPDF.src = ofd.FileName;
                }
            }
        }
    }
}

VIDEO TUTORIALS