The documentation is designed for a specific purpose to help you to apply the features on your side. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can be applied to set PDF viewer selection options and use custompaint event with PDF viewer SDK using VB.NET.
These VB.NET code samples for VB.NET guide developers to speed up coding of the application when using ByteScout Premium Suite. Just copy and paste the code into your VB.NET application’s code and follow the instructions. Further improvement of the code will make it more robust.
All these programming tutorials along with source code samples and ByteScout free trial version are available for download from our website.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Partial Class Form1
''' <summary>
''' Required designer variable.
''' </summary>
Private components As System.ComponentModel.IContainer = Nothing
''' <summary>
''' Clean up any resources being used.
''' </summary>
''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
Protected Overrides Sub Dispose(disposing As Boolean)
If disposing AndAlso (components IsNot Nothing) Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Me.pdfViewerControl1 = New Bytescout.PDFViewer.PDFViewerControl()
Me.toolStrip1 = New System.Windows.Forms.ToolStrip()
Me.tsbOpen = New System.Windows.Forms.ToolStripButton()
Me.cbLockSelection = New System.Windows.Forms.CheckBox()
Me.cbAllowResizeSelection = New System.Windows.Forms.CheckBox()
Me.cbMultiSelectMode = New System.Windows.Forms.CheckBox()
Me.toolStrip1.SuspendLayout()
Me.SuspendLayout()
'
'pdfViewerControl1
'
Me.pdfViewerControl1.AllowResizeSelectionRectangles = True
Me.pdfViewerControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.pdfViewerControl1.BackColor = System.Drawing.SystemColors.ButtonShadow
Me.pdfViewerControl1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.pdfViewerControl1.Location = New System.Drawing.Point(12, 97)
Me.pdfViewerControl1.MouseMode = Bytescout.PDFViewer.MouseMode.Selection
Me.pdfViewerControl1.MultiSelectMode = True
Me.pdfViewerControl1.Name = "pdfViewerControl1"
Me.pdfViewerControl1.RegistrationKey = Nothing
Me.pdfViewerControl1.RegistrationName = Nothing
Me.pdfViewerControl1.Size = New System.Drawing.Size(1153, 568)
Me.pdfViewerControl1.TabIndex = 0
'
'toolStrip1
'
Me.toolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.tsbOpen})
Me.toolStrip1.Location = New System.Drawing.Point(0, 0)
Me.toolStrip1.Name = "toolStrip1"
Me.toolStrip1.Size = New System.Drawing.Size(1177, 25)
Me.toolStrip1.TabIndex = 1
Me.toolStrip1.Text = "toolStrip1"
'
'tsbOpen
'
Me.tsbOpen.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tsbOpen.Name = "tsbOpen"
Me.tsbOpen.Size = New System.Drawing.Size(80, 22)
Me.tsbOpen.Text = "&Open PDF"
'
'cbLockSelection
'
Me.cbLockSelection.AutoSize = True
Me.cbLockSelection.Location = New System.Drawing.Point(12, 74)
Me.cbLockSelection.Name = "cbLockSelection"
Me.cbLockSelection.Size = New System.Drawing.Size(95, 17)
Me.cbLockSelection.TabIndex = 2
Me.cbLockSelection.Text = "Lock selection"
Me.cbLockSelection.UseVisualStyleBackColor = True
'
'cbAllowResizeSelection
'
Me.cbAllowResizeSelection.AutoSize = True
Me.cbAllowResizeSelection.Checked = True
Me.cbAllowResizeSelection.CheckState = System.Windows.Forms.CheckState.Checked
Me.cbAllowResizeSelection.Location = New System.Drawing.Point(12, 51)
Me.cbAllowResizeSelection.Name = "cbAllowResizeSelection"
Me.cbAllowResizeSelection.Size = New System.Drawing.Size(178, 17)
Me.cbAllowResizeSelection.TabIndex = 3
Me.cbAllowResizeSelection.Text = "Allow resize selection rectangles"
Me.cbAllowResizeSelection.UseVisualStyleBackColor = True
'
'cbMultiSelectMode
'
Me.cbMultiSelectMode.AutoSize = True
Me.cbMultiSelectMode.Checked = True
Me.cbMultiSelectMode.CheckState = System.Windows.Forms.CheckState.Checked
Me.cbMultiSelectMode.Location = New System.Drawing.Point(12, 28)
Me.cbMultiSelectMode.Name = "cbMultiSelectMode"
Me.cbMultiSelectMode.Size = New System.Drawing.Size(108, 17)
Me.cbMultiSelectMode.TabIndex = 4
Me.cbMultiSelectMode.Text = "Multi-select mode"
Me.cbMultiSelectMode.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1177, 677)
Me.Controls.Add(Me.cbMultiSelectMode)
Me.Controls.Add(Me.cbAllowResizeSelection)
Me.Controls.Add(Me.cbLockSelection)
Me.Controls.Add(Me.pdfViewerControl1)
Me.Controls.Add(Me.toolStrip1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.toolStrip1.ResumeLayout(False)
Me.toolStrip1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private WithEvents pdfViewerControl1 As Bytescout.PDFViewer.PDFViewerControl
Private WithEvents toolStrip1 As System.Windows.Forms.ToolStrip
Private WithEvents tsbOpen As System.Windows.Forms.ToolStripButton
Private WithEvents cbLockSelection As System.Windows.Forms.CheckBox
Private WithEvents cbAllowResizeSelection As System.Windows.Forms.CheckBox
Private WithEvents cbMultiSelectMode As System.Windows.Forms.CheckBox
End Class
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports Bytescout.PDFViewer
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Sub OnLoad(e As EventArgs)
pdfViewerControl1.InputFile = "sample.pdf"
MyBase.OnLoad(e)
End Sub
Private Sub tsbOpen_Click(sender As Object, e As EventArgs) Handles tsbOpen.Click
Using openFileDialog As New OpenFileDialog()
openFileDialog.Title = "Open PDF Document"
openFileDialog.Filter = "PDF Files (*.pdf)|*.pdf|All Files|*.*"
If openFileDialog.ShowDialog() = DialogResult.OK Then
Me.Text = openFileDialog.FileName
Cursor = Cursors.WaitCursor
Try
pdfViewerControl1.InputFile = openFileDialog.FileName
Catch exception As Exception
MessageBox.Show(exception.Message)
Finally
Cursor = Cursors.[Default]
End Try
End If
End Using
End Sub
Private Sub cbMultiSelectMode_CheckedChanged(sender As Object, e As EventArgs) Handles cbMultiSelectMode.CheckedChanged
pdfViewerControl1.MultiSelectMode = cbMultiSelectMode.Checked
End Sub
Private Sub cbAllowResizeSelection_CheckedChanged(sender As Object, e As EventArgs) Handles cbAllowResizeSelection.CheckedChanged
pdfViewerControl1.AllowResizeSelectionRectangles = cbAllowResizeSelection.Checked
End Sub
Private Sub cbLockSelection_CheckedChanged(sender As Object, e As EventArgs) Handles cbLockSelection.CheckedChanged
pdfViewerControl1.LockSelection = cbLockSelection.Checked
End Sub
Private _labels As List(Of [String]) = New List(Of String)()
Private Sub pdfViewerControl1_SelectionChanged(ByVal sender As Object, ByVal selectionChange As SelectionChange, ByVal selectionIndex As Integer) Handles pdfViewerControl1.SelectionChanged
If pdfViewerControl1.Selection.Length > _labels.Count Then
For i As Integer = _labels.Count To pdfViewerControl1.Selection.Length - 1
_labels.Add(New Random().[Next]().ToString())
Next
End If
End Sub
Private Sub pdfViewerControl1_CustomPaint(sender As Object, e As PaintEventArgs) Handles pdfViewerControl1.CustomPaint
' Paint labels
For i As Integer = 0 To pdfViewerControl1.Selection.Length - 1
Dim r As Rectangle = Rectangle.Round(pdfViewerControl1.Selection(i))
r = pdfViewerControl1.TranslateRectangleToViewport(r)
Dim textSize As Size = TextRenderer.MeasureText(_labels(i), Font)
Dim textRectangle As New Rectangle(r.Left, r.Top - textSize.Height - 6, textSize.Width + 2, textSize.Height + 2)
e.Graphics.FillRectangle(Brushes.DarkBlue, textRectangle)
TextRenderer.DrawText(e.Graphics, _labels(i), Font, textRectangle, Color.White, TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter)
Next
End Sub
End Class
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
Imports System.Collections.Generic
Imports System.Windows.Forms
NotInheritable Class Program
Private Sub New()
End Sub
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Private Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: