Viscomsoft .NET PDF Viewer SDK

VB.NET Developer Getting Started



1. Launch Visual Studio 2010 or another version of Visual Studio. Select Visual Basic, Select Windows Form Application.

 


 

2. In the Solution Explorer, right-click References, and then click Add Reference.


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




4. At the top of the Form1.vb file, add the following import statements to the top of the page
 

Imports Viscomsoft.PDFViewer


5.  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

6.  Load 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)

 _pdfviewer.ContinuousPages = True

 'let scrolling the pdf file using the mouse wheel
_pdfviewer.Canvas.Select()


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


7Now 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

8.  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)

_pdfviewer.ContinuousPages = True

 'let scrolling the pdf file using the mouse wheel
_pdfviewer.Canvas.Select()

resizeCanvas()

Dim doc As New PDFDocument

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

 _pdfviewer.Document = doc

 _pdfviewer.gotoPage(1)

Else

 doc.close()

End If

End Sub

9.  add resizeCanvas() in Form1_Resize event

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

resizeCanvas()

End Sub

 

10.  Press F5 to Run the project, now it can loading and display the PDF document.