Windows Forms: How to Open and Show a PDF file in C#
By FoxLearn 7/31/2017 9:58:34 PM 15.23K
How to open, show a PDF file in C# using Adobe Acrobat embed pdf to windows form
Step 1: Click 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
Step 2: Design your form as below
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
- How to save files using SaveFileDialog in C#
- How to make an Alarm clock with sound in C#
- How to Display Images in DataGridView in C#
- How to Print DataGridView with Header & Footer with Landscape in C#
- How to Create a custom Progress Bar with Percentage in C#
- How to read an image file in C#
- How to use BackgroundWorker in C#
- How to protect .NET code from reverse engineering
Categories
Popular Posts
Flat Able Admin Dashboard Template
11/18/2024
Regal Admin Dashboard Template
11/18/2024
Plus Admin Dashboard Template
11/18/2024
Admin Tailwind CSS Admin Dashboard Template
11/18/2024