in this post, how is it created “PDF File Reader” in C# windows form Application? We Will create a winform app about this issue.
The .Net framework does not provide a library to easily handle PDF files in .Net.
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 Form Application and add the control to the C# Toolbox.
Step 1: Right-click on any tab of toolbox and select “Choose Items”.
Step 2: Select the “COM Components” tab and click the check “Adobe PDF Reader” and click OK.
Step 2: You will see the Adobe PDF Reader control icon in the toolbox, then you can drag and drop this control onto your form. The contents of the PDF file will appear here.
Form Design
Step 3: Right click on Adobe PDF Reader and in the Properties window, set the Dock property as “Fill”
Source Code:
openToolStripMenuItem_Click
1 2 3 4 5 6 7 8 9 10 11 12 13 | private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog file = new OpenFileDialog(); file.Filter = "PDF Files |*.pdf"; file.ShowDialog(); if(file.FileName!="") { axAcroPDF1.LoadFile(file.FileName); } } |
exitToolStripMenuItem_Click
1 2 3 4 5 6 7 | private void exitToolStripMenuItem_Click(object sender, EventArgs e) { axAcroPDF1.Dispose(); this.Close(); } |
Output: