Some test text!

Search
Hamburger Icon

VB PDF Viewer control

More languages

More languages
C++
C#
VB

Sample VB code for using PDFTron SDK's PDF viewer control in a basic project. This sample uses a number of built-in features from PDFViewCtrl to open PDF files, implement document navigation, text highlighting, markup, and editing. If you are looking for a sample showing how to further customize the viewer (e.g. by implementing custom tools or custom GUI elements), please take a look at the PDFView sample code. Learn more about our VB PDF Library and PDF Viewer SDK.

Get Started Samples Download

To run this sample, get started with a free trial of Apryse SDK.

Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms

Imports pdftron
Imports pdftron.PDF
Imports pdftron.Filters
Imports pdftron.Common
Imports pdftron.SDF

Namespace PDFViewSimpleTestVB
    Module PDFViewSimpleTestVB
        Dim pdfNetLoader As PDFNetLoader
        Sub New()
            pdfNetLoader = pdftron.PDFNetLoader.Instance()
        End Sub

        <STAThread()> Sub Main()
            PDFNet.Initialize(PDFTronLicense.Key)
            Application.Run(New PDFViewSimple)
        End Sub
    End Module
End Namespace

Public Class PDFViewSimple
    Inherits System.Windows.Forms.Form
    Private components As System.ComponentModel.IContainer
    Private mainMenu1 As System.Windows.Forms.MainMenu
    Private menuItem1 As System.Windows.Forms.MenuItem
    Private menuItem5 As System.Windows.Forms.MenuItem
    Private WithEvents MenuFileOpen As System.Windows.Forms.MenuItem
    Private WithEvents MenuFileExit As System.Windows.Forms.MenuItem
    Private _pdfview As PDFViewCtrl
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuViewZoomIn As System.Windows.Forms.MenuItem
    Friend WithEvents MenuViewZoomOut As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFileSave As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFileSaveAs As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFilePrint As System.Windows.Forms.MenuItem
    Friend WithEvents MenuEditFind As System.Windows.Forms.MenuItem
    Friend WithEvents MenuEditCopy As System.Windows.Forms.MenuItem
    Friend WithEvents MenuEditSelectAll As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem14 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuSinglePage As System.Windows.Forms.MenuItem
    Friend WithEvents MenuSingleContinuous As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFacing As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFacingContinuous As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem15 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFitPage As System.Windows.Forms.MenuItem
    Friend WithEvents MenuFitWidth As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolPan As System.Windows.Forms.MenuItem
    Friend WithEvents MenuGotoNext As System.Windows.Forms.MenuItem
    Friend WithEvents MenuHelpAbout As System.Windows.Forms.MenuItem
    Friend WithEvents MenuGotoPrev As System.Windows.Forms.MenuItem
    Friend WithEvents MenuGotoLast As System.Windows.Forms.MenuItem
    Friend WithEvents MenuGotoFirst As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolStructSelect As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolRectSelect As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolRectZoomIn As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolRectZoomOut As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolAnnotEdit As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolLineCreate As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolRectCreate As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolOvalCreate As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolArrayCreate As System.Windows.Forms.MenuItem
    Friend WithEvents MenuToolFreeHand As System.Windows.Forms.MenuItem
    Private _pdfdoc As PDFDoc

    Public Sub New()
        InitializeComponent()
        _pdfview = New PDFViewCtrl
        _pdfview.Location = New System.Drawing.Point(0, 0)
        _pdfview.Dock = System.Windows.Forms.DockStyle.Fill
        Controls.Add(_pdfview)
    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.mainMenu1 = New System.Windows.Forms.MainMenu
        Me.menuItem1 = New System.Windows.Forms.MenuItem
        Me.MenuFileOpen = New System.Windows.Forms.MenuItem
        Me.MenuFileSave = New System.Windows.Forms.MenuItem
        Me.MenuFileSaveAs = New System.Windows.Forms.MenuItem
        Me.MenuFilePrint = New System.Windows.Forms.MenuItem
        Me.menuItem5 = New System.Windows.Forms.MenuItem
        Me.MenuFileExit = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.MenuEditFind = New System.Windows.Forms.MenuItem
        Me.MenuEditCopy = New System.Windows.Forms.MenuItem
        Me.MenuEditSelectAll = New System.Windows.Forms.MenuItem
        Me.MenuItem3 = New System.Windows.Forms.MenuItem
        Me.MenuItem14 = New System.Windows.Forms.MenuItem
        Me.MenuSinglePage = New System.Windows.Forms.MenuItem
        Me.MenuSingleContinuous = New System.Windows.Forms.MenuItem
        Me.MenuFacing = New System.Windows.Forms.MenuItem
        Me.MenuFacingContinuous = New System.Windows.Forms.MenuItem
        Me.MenuItem15 = New System.Windows.Forms.MenuItem
        Me.MenuFitPage = New System.Windows.Forms.MenuItem
        Me.MenuFitWidth = New System.Windows.Forms.MenuItem
        Me.MenuViewZoomIn = New System.Windows.Forms.MenuItem
        Me.MenuViewZoomOut = New System.Windows.Forms.MenuItem
        Me.MenuItem4 = New System.Windows.Forms.MenuItem
        Me.MenuToolPan = New System.Windows.Forms.MenuItem
        Me.MenuToolStructSelect = New System.Windows.Forms.MenuItem
        Me.MenuToolRectSelect = New System.Windows.Forms.MenuItem
        Me.MenuToolRectZoomIn = New System.Windows.Forms.MenuItem
        Me.MenuToolRectZoomOut = New System.Windows.Forms.MenuItem
        Me.MenuToolAnnotEdit = New System.Windows.Forms.MenuItem
        Me.MenuToolLineCreate = New System.Windows.Forms.MenuItem
        Me.MenuToolRectCreate = New System.Windows.Forms.MenuItem
        Me.MenuToolOvalCreate = New System.Windows.Forms.MenuItem
        Me.MenuToolArrayCreate = New System.Windows.Forms.MenuItem
        Me.MenuToolFreeHand = New System.Windows.Forms.MenuItem
        Me.MenuItem6 = New System.Windows.Forms.MenuItem
        Me.MenuGotoNext = New System.Windows.Forms.MenuItem
        Me.MenuGotoPrev = New System.Windows.Forms.MenuItem
        Me.MenuGotoLast = New System.Windows.Forms.MenuItem
        Me.MenuGotoFirst = New System.Windows.Forms.MenuItem
        Me.MenuItem7 = New System.Windows.Forms.MenuItem
        Me.MenuHelpAbout = New System.Windows.Forms.MenuItem
        Me.SuspendLayout()
        '
        'mainMenu1
        '
        Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem1, Me.MenuItem2, Me.MenuItem3, Me.MenuItem4, Me.MenuItem6, Me.MenuItem7})
        '
        'menuItem1
        '
        Me.menuItem1.Index = 0
        Me.menuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuFileOpen, Me.MenuFileSave, Me.MenuFileSaveAs, Me.MenuFilePrint, Me.menuItem5, Me.MenuFileExit})
        Me.menuItem1.Text = "File"
        '
        'MenuFileOpen
        '
        Me.MenuFileOpen.Index = 0
        Me.MenuFileOpen.Text = "Open"
        '
        'MenuFileSave
        '
        Me.MenuFileSave.Index = 1
        Me.MenuFileSave.Text = "Save"
        '
        'MenuFileSaveAs
        '
        Me.MenuFileSaveAs.Index = 2
        Me.MenuFileSaveAs.Text = "Save As"
        '
        'MenuFilePrint
        '
        Me.MenuFilePrint.Index = 3
        Me.MenuFilePrint.Text = "Print"
        '
        'menuItem5
        '
        Me.menuItem5.Index = 4
        Me.menuItem5.Text = "-"
        '
        'MenuFileExit
        '
        Me.MenuFileExit.Index = 5
        Me.MenuFileExit.Text = "Exit"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 1
        Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuEditFind, Me.MenuEditCopy, Me.MenuEditSelectAll})
        Me.MenuItem2.Text = "Edit"
        '
        'MenuEditFind
        '
        Me.MenuEditFind.Index = 0
        Me.MenuEditFind.Text = "Find..."
        '
        'MenuEditCopy
        '
        Me.MenuEditCopy.Index = 1
        Me.MenuEditCopy.Text = "Copy"
        '
        'MenuEditSelectAll
        '
        Me.MenuEditSelectAll.Index = 2
        Me.MenuEditSelectAll.Text = "Select All"
        '
        'MenuItem3
        '
        Me.MenuItem3.Index = 2
        Me.MenuItem3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem14, Me.MenuItem15, Me.MenuViewZoomIn, Me.MenuViewZoomOut})
        Me.MenuItem3.Text = "View"
        '
        'MenuItem14
        '
        Me.MenuItem14.Index = 0
        Me.MenuItem14.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuSinglePage, Me.MenuSingleContinuous, Me.MenuFacing, Me.MenuFacingContinuous})
        Me.MenuItem14.Text = "Page Layout"
        '
        'MenuSinglePage
        '
        Me.MenuSinglePage.Index = 0
        Me.MenuSinglePage.Text = "Single Page"
        '
        'MenuSingleContinuous
        '
        Me.MenuSingleContinuous.Index = 1
        Me.MenuSingleContinuous.Text = "Single Continuous"
        '
        'MenuFacing
        '
        Me.MenuFacing.Index = 2
        Me.MenuFacing.Text = "Facing"
        '
        'MenuFacingContinuous
        '
        Me.MenuFacingContinuous.Index = 3
        Me.MenuFacingContinuous.Text = "Facing Continuous"
        '
        'MenuItem15
        '
        Me.MenuItem15.Index = 1
        Me.MenuItem15.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuFitPage, Me.MenuFitWidth})
        Me.MenuItem15.Text = "Page ViewMode"
        '
        'MenuFitPage
        '
        Me.MenuFitPage.Index = 0
        Me.MenuFitPage.Text = "Fit Page"
        '
        'MenuFitWidth
        '
        Me.MenuFitWidth.Index = 1
        Me.MenuFitWidth.Text = "Fit Width"
        '
        'MenuViewZoomIn
        '
        Me.MenuViewZoomIn.Index = 2
        Me.MenuViewZoomIn.Text = "Zoom In"
        '
        'MenuViewZoomOut
        '
        Me.MenuViewZoomOut.Index = 3
        Me.MenuViewZoomOut.Text = "Zoom Out"
        '
        'MenuItem4
        '
        Me.MenuItem4.Index = 3
        Me.MenuItem4.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuToolPan, Me.MenuToolStructSelect, Me.MenuToolRectSelect, Me.MenuToolRectZoomIn, Me.MenuToolRectZoomOut, Me.MenuToolAnnotEdit, Me.MenuToolLineCreate, Me.MenuToolRectCreate, Me.MenuToolOvalCreate, Me.MenuToolArrayCreate, Me.MenuToolFreeHand})
        Me.MenuItem4.Text = "Tool"
        '
        'MenuToolPan
        '
        Me.MenuToolPan.Index = 0
        Me.MenuToolPan.Text = "Pan"
        '
        'MenuToolStructSelect
        '
        Me.MenuToolStructSelect.Index = 1
        Me.MenuToolStructSelect.Text = "Structural Selection"
        '
        'MenuToolRectSelect
        '
        Me.MenuToolRectSelect.Index = 2
        Me.MenuToolRectSelect.Text = "Rectangle Selection"
        '
        'MenuToolRectZoomIn
        '
        Me.MenuToolRectZoomIn.Index = 3
        Me.MenuToolRectZoomIn.Text = "Rectangle Zoom In"
        '
        'MenuToolRectZoomOut
        '
        Me.MenuToolRectZoomOut.Index = 4
        Me.MenuToolRectZoomOut.Text = "Rectangle Zoom Out"
        '
        'MenuToolAnnotEdit
        '
        Me.MenuToolAnnotEdit.Index = 5
        Me.MenuToolAnnotEdit.Text = "Annotation Editing"
        '
        'MenuToolLineCreate
        '
        Me.MenuToolLineCreate.Index = 6
        Me.MenuToolLineCreate.Text = "Line Creation"
        '
        'MenuToolRectCreate
        '
        Me.MenuToolRectCreate.Index = 7
        Me.MenuToolRectCreate.Text = "Rectangle Creation"
        '
        'MenuToolOvalCreate
        '
        Me.MenuToolOvalCreate.Index = 8
        Me.MenuToolOvalCreate.Text = "Oval Creation"
        '
        'MenuToolArrayCreate
        '
        Me.MenuToolArrayCreate.Index = 9
        Me.MenuToolArrayCreate.Text = "Arrow Creation"
        '
        'MenuToolFreeHand
        '
        Me.MenuToolFreeHand.Index = 10
        Me.MenuToolFreeHand.Text = "FreeHand Tool"
        '
        'MenuItem6
        '
        Me.MenuItem6.Index = 4
        Me.MenuItem6.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuGotoNext, Me.MenuGotoPrev, Me.MenuGotoLast, Me.MenuGotoFirst})
        Me.MenuItem6.Text = "Page Navigation"
        '
        'MenuGotoNext
        '
        Me.MenuGotoNext.Index = 0
        Me.MenuGotoNext.Text = "Go to Next Page"
        '
        'MenuGotoPrev
        '
        Me.MenuGotoPrev.Index = 1
        Me.MenuGotoPrev.Text = "Go to Previous Page"
        '
        'MenuGotoLast
        '
        Me.MenuGotoLast.Index = 2
        Me.MenuGotoLast.Text = "Go to Last Page"
        '
        'MenuGotoFirst
        '
        Me.MenuGotoFirst.Index = 3
        Me.MenuGotoFirst.Text = "Go to First Page"
        '
        'MenuItem7
        '
        Me.MenuItem7.Index = 5
        Me.MenuItem7.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuHelpAbout})
        Me.MenuItem7.Text = "Help"
        '
        'MenuHelpAbout
        '
        Me.MenuHelpAbout.Index = 0
        Me.MenuHelpAbout.Text = "About..."
        '
        'PDFViewSimple
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(744, 512)
        Me.Menu = Me.mainMenu1
        Me.Name = "PDFViewSimple"
        Me.Text = "PDFViewSimple"
        Me.ResumeLayout(False)

    End Sub

    Private Sub menuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFileOpen.Click
        Dim dlg As OpenFileDialog = New OpenFileDialog
        dlg.CheckFileExists = True
        dlg.CheckPathExists = True
        dlg.Filter = "PDF (*.pdf)|*.pdf|All files (*.*)|*.*"
        dlg.DefaultExt = ".pdf"
        If dlg.ShowDialog = DialogResult.OK Then
            OpenPDF(dlg.FileName)
        End If
    End Sub

    Public Function OpenPDF(ByVal filename As String) As Boolean
        Try
            'close old document if opening new file was successful
            Dim olddoc As PDFDoc = _pdfview.GetDoc()
            _pdfdoc = New PDFDoc(filename)
            _pdfview.SetDoc(_pdfdoc)

            ' Use built-in navigation (thumbnails, bookmarks, layers, etc)?
            ' _pdfview.ShowNavToolbar(true)
            ' _pdfview.ShowNavPanel(true)

            If Not (olddoc Is Nothing) Then
                olddoc.Dispose()
            End If

        Catch ex As PDFNetException
            MessageBox.Show(ex.Message)
            Return False
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Return False
        End Try
        Me.Text = filename
        Return True
    End Function

    Private Sub MenuFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFileSave.Click
        If Not (_pdfdoc Is Nothing) Then
            Me.Save(Me.Text)
        End If
    End Sub

    Private Sub MenuFileSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFileSaveAs.Click
        If Not (_pdfdoc Is Nothing) AndAlso Not (_pdfview Is Nothing) Then
            'opens a save dialog
            Dim dlg As SaveFileDialog = New SaveFileDialog
            dlg.Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
            dlg.DefaultExt = ".pdf"
            dlg.FileName = Text
            Dim res As DialogResult = dlg.ShowDialog
            If res = DialogResult.OK Then
                'saves the file
                Me.Save(dlg.FileName)
            End If
        End If
    End Sub

    Public Sub Save(ByVal fileName As String)
        _pdfdoc.Lock()
        Try
            _pdfdoc.Save(fileName, SDFDoc.SaveOptions.e_remove_unused)
        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Error during the Save")
        End Try
        _pdfdoc.Unlock()
    End Sub

    Private Sub MenuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFilePrint.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.Print()
        End If
    End Sub

    Private Sub MenuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFileExit.Click
        PDFNet.Terminate()
        Application.Exit()
    End Sub


    Private Sub MenuEditCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuEditCopy.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.Copy()
        End If
    End Sub

    Private Sub MenuEditFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuEditFind.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.Find()
        End If
    End Sub

    Private Sub MenuEditSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuEditSelectAll.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SelectAll()
        End If
    End Sub

    Private Sub MenuViewZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuViewZoomIn.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetZoom(_pdfview.GetZoom() * 2)
        End If
    End Sub


    Private Sub MenuViewZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuViewZoomOut.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetZoom(_pdfview.GetZoom() / 2)
        End If
    End Sub

    Private Sub MenuNextPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuGotoNext.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.GotoNextPage()
        End If
    End Sub

    Private Sub MenuPreviousPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuGotoPrev.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.GotoPreviousPage()
        End If
    End Sub

    Private Sub MenuLastPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuGotoLast.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.GotoLastPage()
        End If
    End Sub

    Private Sub MenuFirstPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuGotoFirst.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.GotoFirstPage()
        End If
    End Sub

    Private Sub MenuPageLayoutSinglePage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuSinglePage.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_single_page)
        End If
    End Sub

    Private Sub MenuPageLayoutSingleContinous_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuSingleContinuous.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_single_continuous)
        End If
    End Sub

    Private Sub MenuPageLayoutFacing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFacing.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_facing)
        End If
    End Sub

    Private Sub MenuPageLayoutFacingContinuous_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFacingContinuous.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_facing_continuous)
        End If
    End Sub

    Private Sub MenuPageViewModeFitPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFitPage.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPageViewMode(PDFViewCtrl.PageViewMode.e_fit_page)
        End If
    End Sub

    Private Sub MenuPageViewModeFitWidth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFitWidth.Click
        If Not (_pdfview.GetDoc() Is Nothing) Then
            _pdfview.SetPageViewMode(PDFViewCtrl.PageViewMode.e_fit_width)
        End If
    End Sub

    Private Sub MenuToolPan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolPan.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_pan)
    End Sub

    Private Sub MenuToolStructuralSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolStructSelect.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_text_struct_select)
    End Sub

    Private Sub MenuToolRectangleSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolRectSelect.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_text_rect_select)
    End Sub

    Private Sub MenuToolRectangleZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolRectZoomIn.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_zoom_in)
    End Sub

    Private Sub MenuToolRectangleZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolRectZoomOut.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_zoom_out)
    End Sub

    Private Sub MenuToolAnnotationEditing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolAnnotEdit.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_annot_edit)
    End Sub

    Private Sub MenuToolLineCreation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolLineCreate.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_line_create)
    End Sub

    Private Sub MenuToolRectangleCreation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolRectCreate.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_rect_create)
    End Sub

    Private Sub MenuToolOvalCreation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolOvalCreate.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_oval_create)
    End Sub

    Private Sub MenuToolArrowCreation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolArrayCreate.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_arrow_create)
    End Sub

    Private Sub MenuToolFreeHandToolCreation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuToolFreeHand.Click
        _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_ink_create)
    End Sub

    Private Sub MenuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuHelpAbout.Click
        MessageBox.Show("PDFView Sample Application, Version 1.0", "About PDFViewSimple")
    End Sub

End Class