.NET PDF Viewer SDK

.NET PDF Viewer SDK

Platform : Windows 10, Windows 8, Vista, Windows 7

With .NET PDF Viewer SDK , the developer can easily add PDF, TIFF viewer and Continuous scroll (like in Adobe Reader) capability to their application. 

Popular Solution Go   Back

VB.NET - How to Open a PDF File in VB.NET

Step 1: To install the .NET PDF Viewer SDK, begin by launching the setup file (dotnet_pdf_viewer_sdk_setup.exe). Select the desired installation folder for the .NET PDF Viewer SDK and continue with the installation on your development computer.

Step 2: Launch Visual Studio 2010 or another version of Visual Studio. Select Visual Basic, Select Windows Form Application.

Step 3: In the Solution Explorer, right-click References, and then click Add Reference.

 

 

 Step 4: Select Browse tab,  Navigate to the extracted  .NET PDF Viewer SDK for REDIST folder, open it, and select  Viscomsoft.PDFViewer.dll, ViscomsoftPDFCore.dll

 

Step 5: At the top of the Form1.vb file, add the following import statements to the top of the page

Imports Viscomsoft.PDFViewer

 

Step 6: The following code bit presents the pdf viewer sdk initialization:

Public Class Form1

Dim _pdfviewer As New PDFView

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

_pdfviewer.Canvas.Parent = Me

_pdfviewer.Canvas.Location = New Point(0, 24)

_pdfViewer.ContinuousPages = true

//let scrolling the pdf file using the mouse wheel
_pdfViewer.Canvas.Select()

End Sub

 

Step 7:  The following code load and view the PDF file.

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

_pdfviewer.Canvas.Parent = Me

_pdfviewer.Canvas.Location = New Point(0, 24)

  Dim doc As New PDFDocument

   If doc.open("c:\yourfile.pdf") Then

      _pdfviewer.Document = doc

      _pdfviewer.gotoPage(1)

   Else

      doc.close()

   End If

End Sub

 

Step 8. Now that you can loaded a PDF file, but the display area is very small. so add following code to the Form1.vb file

Private Sub resizeCanvas()

   _pdfviewer.Canvas.Size = New Size(Me.ClientSize.Width, Me.ClientSize.Height - 24)

End Sub

 

Step 9. add resizeCanvas() in Form1_Load event

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

_pdfviewer.Canvas.Parent = Me

_pdfviewer.Canvas.Location = New Point(0, 24)

resizeCanvas()

 Dim doc As New PDFDocument

 If doc.open("c:\yourfile.pdf") Then

  _pdfviewer.Document = doc

  _pdfviewer.gotoPage(1)

 Else

_doc.close()

 End If

End Sub

 

Step 10. add resizeCanvas() in Form1_Resize event

Private Sub Form1_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize

 resizeCanvas()

End Sub 

 

Step 11. Press F5 to Run the project, now it can loading and view the PDF document.