Untitled

mail@pastecode.io avatar
unknown
plain_text
8 days ago
958 B
1
Indexable
Never
Imports System.IO
Imports PdfiumViewer

Public Class Form1

    Private pdfViewer As PdfViewer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Initialize PdfViewer
        pdfViewer = New PdfViewer()
        pdfViewer.Dock = DockStyle.Fill
        Panel2.Controls.Add(pdfViewer)

        ' Load file names into ListBox
        Dim pdfFiles = Directory.GetFiles("path_to_your_pdf_files", "*.pdf")
        For Each file In pdfFiles
            ListBox1.Items.Add(Path.GetFileName(file))
        Next
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        ' Display selected PDF file
        Dim selectedFile = Path.Combine("path_to_your_pdf_files", ListBox1.SelectedItem.ToString())
        Dim pdfDocument = PdfDocument.Load(selectedFile)
        pdfViewer.Document = pdfDocument
    End Sub

End Class
Leave a Comment