Open and View PDF File in Visual Basic.Net

Download
Download is available until [expire_date]
  • Version
  • Download 205
  • File Size 499.81 KB
  • File Count 1
  • Create Date March 11, 2016
  • Last Updated March 11, 2016

Open and View PDF File in Visual Basic.Net

Open and View PDF File in Visual Basic.Net

This program will allow you to select a PDF file from your computer and open and view it in a form of visual basic.net.

To use the PDF viewer component, you need to add first in the toolbox.

Right- Toolbox, and then select Choose Items. A dialog box will appear, select the COM Components tab, select or check Adobe PDF Reader and click OK.

Source code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListboxItems()
    End Sub
    Private Sub ListboxItems()
        ListBox1.Items.Add("PDF 1")
        ListBox1.Items.Add("PDF 2")
        ListBox1.Items.Add("PDF 3")
        ListBox1.Items.Add("PDF 4")
        ListBox1.Items.Add("PDF 5")
    End Sub

    Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
        If ListBox1.SelectedItem = "PDF 1" Then
            AxAcroPDF1.src = My.Application.Info.DirectoryPath & "pdf1.pdf"
        ElseIf ListBox1.SelectedItem = "PDF 2" Then
            AxAcroPDF1.src = My.Application.Info.DirectoryPath & "pdf2.pdf"
        ElseIf ListBox1.SelectedItem = "PDF 3" Then
            AxAcroPDF1.src = My.Application.Info.DirectoryPath & "pdf3.pdf"
        ElseIf ListBox1.SelectedItem = "PDF 4" Then
            AxAcroPDF1.src = My.Application.Info.DirectoryPath & "pdf4.pdf"
        ElseIf ListBox1.SelectedItem = "PDF 5" Then
            AxAcroPDF1.src = My.Application.Info.DirectoryPath & "pdf5.pdf"
        End If
    End Sub

   
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Filter = "PDF Files (*.pdf)|*.pdf"

        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            AxAcroPDF1.src = OpenFileDialog1.FileName
        End If
    End Sub
End Class
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.