To display
PDF in Windows Application:
- Start a new Windows Project
- Right Click on the tool box and Click on “Choose Items”
- You will get the following “Choose Toolbox Items” window. Go to “COM Components” Tab and check “Adobe PDF Reader” and click on “OK”
- You will now find the adobe control in the tool boxes.
- In the Design View Drag and drop Adobe PDF reader Control and a Button Control
On the button click event add the following
code:
VB.Net code
Private Sub
Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim dlg
As OpenFileDialog
dlg = New OpenFileDialog()
dlg.Filter = "pdf
files (*.pdf) |*.pdf;"
dlg.ShowDialog()
If (Not String.IsNullOrEmpty(dlg.FileName))
Then
AxAcroPDF1.LoadFile(dlg.FileName)
End If
End Sub
C# .Net Code
private void
button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg
= new OpenFileDialog();
dlg.Filter = "pdf files (*.pdf) |*.pdf;";
dlg.ShowDialog();
if(dlg.FileName
!= null)
{
axAcroPDF1.LoadFile(dlg.FileName);
}
}
Output:
No comments:
Post a Comment