Click here to Skip to main content
12,549,181 members (46,366 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked

InkCollector Signiture Made Easy

, 23 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
InkCollector Signiture as a String Made Easy


The following article is useful when trying to import Ink into a database. I have tried to keep it as simple as possible.


I've successfully used this in my Access database that holds about 500 signatures; the average signature size is about 1500 characters. The largest one on record is 2853 and the smallest one on record is 1139. To store this in a Microsoft Access Database, you will need to save it in a memo field as the maximum number of characters in a Text field is 255.

Using the Code

First add the reference for Microsoft.Ink to your VB Project, next create a group box on your form. Before your form class, add Imports Microsoft.Ink so that a InkCollector control can be created. First, define the InkCollector control. Then, create the control from your form load sub and give it the handle of your group box.

Your code should then look something like this:

Imports Microsoft.Ink 'Required for InkCollector

Public Class frmMain

    Dim Sig_InkCollector As InkCollector 'The InkCollector

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
	Handles Me.Load
        Sig_InkCollector = New InkCollector(GroupBox1.Handle)
        Sig_InkCollector.Enabled = True
        Sig_InkCollector.AutoRedraw = True
    End Sub
End Class

I have just completed adding a function that converts the base64 string to an image so that it can be attached to a RTF, HTML or printed easily.

To Clear the Signiture

Specify call the clear sub from the Signiture module, then specify the InkCollector and the GroupBox which contains the InkCollector control.

Signiture.Clear(Sig_InkCollector, GroupBox1)

To Set the Signiture

To load a signiture Base64 string into the inkCollector, call the following Sub, specify the InkCollector and the GroupBox which contains the InkCollector control, then the Base64 String.

Signiture.SetBase64(Sig_InkCollector, GroupBox1, TextBox1.Text)

To Get the Signiture

To read the Signiture from the InkCollector, call the following function and specify the InkCollector. The Base64 String will be returned.

Textbox1.Text = Signiture.GetBase64(Sig_InkCollector) 

To Convert Base64 to Image

To convert a stored Base64InkSerializedFormat String to an Image, so that the signiture can be displayed in a report.

PictureBox1.Image = Signiture.Base64toImage(TextBox1.Text) 


Imports Microsoft.Ink 'Required for InkPicture
Imports System.Text 'Required by UTF8Encoding
Imports System.IO 'Required by MemoryStream
''' <summary>
''' Signiture Made Easy Module
''' Created by Marco van der Merwe (22 September 2010)
''' </summary>
Module Signiture
''' <summary>
''' Returns String in Format(PersistenceFormat = Base64InkSerializedFormat)
''' </summary>
''' <param name="InkCollector"></param>
''' <returns> String Format(PersistenceFormat = Base64InkSerializedFormat)</returns>
''' <remarks></remarks>
Function GetBase64(ByVal InkCollector As InkCollector) As String
Dim utf8 As UTF8Encoding = New UTF8Encoding()
InkCollector.Enabled = False
Return utf8.GetString(InkCollector.Ink.Save_
	(PersistenceFormat.Base64InkSerializedFormat, CompressionMode.Maximum))
InkCollector.Enabled = True
End Function
''' <summary>
''' Sets the Base 64 Ink from String
''' </summary>
''' <param name="InkCollector"></param>
''' <param name="GroupBox"></param>
''' <param name="Base64"></param>
''' <remarks></remarks>
Sub SetBase64(ByVal InkCollector As InkCollector, _
	ByVal GroupBox As GroupBox, ByVal Base64 As String)
Dim loadedInk As Ink = New Ink()
Dim utf8 As UTF8Encoding = New UTF8Encoding()
InkCollector.Enabled = False
InkCollector.Ink.DeleteStrokes() ' Clear all strokes
InkCollector.Ink = loadedInk
InkCollector.Enabled = True
End Sub
''' <summary>
''' Clear Signiture
''' </summary>
''' <param name="InkCollector"></param>
''' <param name="GroupBox"></param>
''' <remarks></remarks>
Sub Clear(ByVal InkCollector As InkCollector, ByVal GroupBox As GroupBox)
InkCollector.Enabled = False ' Disable InkPicture to clear
InkCollector.Ink.DeleteStrokes() ' Clear all strokes
GroupBox.Invalidate() ' Redraw frame
InkCollector.Enabled = True ' Reenale InkPicture for entry
End Sub
''' <summary>
''' Converts String Format(PersistenceFormat = Base64InkSerializedFormat) 
''' to System.Drawing.Image
''' </summary>
''' <param name="Base64"></param>
''' <returns>System.Drawing.Image</returns>
''' <remarks></remarks>
Function Base64toImage(ByVal Base64 As String) As System.Drawing.Image
Dim utf8 As UTF8Encoding = New UTF8Encoding()
Dim imgSig As System.Drawing.Image
Dim tmploadedInk As Ink = New Ink()
Dim strGIF As String
Dim imageBytes() As Byte
Dim MS As MemoryStream
'Load the Base64 String in Format(PersistenceFormat = Base64InkSerializedFormat) as ink
'Convert the ink to Base64 String in format 
'(PersistenceFormat.Gif, CompressionMode.Maximum)
strGIF = Convert.ToBase64String(tmploadedInk.Save_
	(PersistenceFormat.Gif, CompressionMode.Maximum))
'Convert Base64 String to Byte Array
imageBytes = Convert.FromBase64String(strGIF)
MS = New MemoryStream(imageBytes, 0, imageBytes.Length)
' Convert byte[] to Image
MS.Write(imageBytes, 0, imageBytes.Length)
imgSig = Image.FromStream(MS, True)
Return imgSig
End Function
End Module

Points of Interest

I’ve tried everything with InkPicture for about 3 weeks and had no results, until I started using InkCollector. I had many unexplained errors and very little help with InkPicture, this is far easier to use.

I know the Access Database gets quite large, but at least these signitures are secured by a password and my data is at least stored in the same database.


  • Added Image Support, to convert Base64InkSerializedFormat string to Image


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Qatar Qatar
My love for imagining, designing and creating just about anything REAL or VIRTUAL has lead me on this path. Whether it be 1’s and 0’s, soldering an IC to a PCB or getting under the car just to get my hands dirty, I like to DIY.
Life is a journey, and it’s all about learning and creating…

Some Achievements in my life:
• Founder of the Doha College Robotics Club
• President and founder of the CNA-Q Robotics Club
• Developed Fly-By-Wire Over Ethernet (FBWOE) for boats.
• Telecommunication Engineering Technology Diploma
• X10 Home Automation system as part of a Green Home project
Developed a Vehicle Accessory Computer Interface (VACI)
• Autonomos Turtle Monitoring Robot
Virtual Autonomous Remote Presence (VARP)
• Electrical Engineering Degree from Purdue
• Various Industrial Automation projects ranging from manufacturing car parts to plastics, shaving cream and even ice-cream. I have worked with various robotic systems, VFD's, HMI's, PLCs, industrial networking/data collection systems, and Machine Vision systems.

You may also be interested in...


Comments and Discussions

QuestionMs Access Database Pin
Member 126183725-Jul-16 9:38
memberMember 126183725-Jul-16 9:38 
QuestionHow to get the signature from a hand held device like a tablet or mobile phone instead of mouse? Pin
Member 1182793915-Apr-16 0:07
memberMember 1182793915-Apr-16 0:07 
AnswerRe: How to get the signature from a hand held device like a tablet or mobile phone instead of mouse? Pin
OriginalGriff15-Apr-16 0:09
protectorOriginalGriff15-Apr-16 0:09 
GeneralRe: How to get the signature from a hand held device like a tablet or mobile phone instead of mouse? Pin
Member 1182793915-Apr-16 0:17
memberMember 1182793915-Apr-16 0:17 
GeneralRe: How to get the signature from a hand held device like a tablet or mobile phone instead of mouse? Pin
OriginalGriff15-Apr-16 0:26
protectorOriginalGriff15-Apr-16 0:26 
QuestionWhen i try adding similar code base as user control and not Windows doesn't capture movement Pin
shreytech16-Jul-15 12:55
membershreytech16-Jul-15 12:55 
QuestionC# Pin
vishal jodh14-May-13 0:40
membervishal jodh14-May-13 0:40 
Questiongetting signature from databse Pin
Shine10003-Mar-12 5:52
memberShine10003-Mar-12 5:52 
HI, I am trying to work with your program and make some experiments.(i hope you dont mind). I try to store them to database but i dont know how successful i am since i cant fetch them from database..
QuestionLimiting size of signature Pin
Member 863721411-Feb-12 21:28
memberMember 863721411-Feb-12 21:28 
AnswerRe: Limiting size of signature Pin
bigbro_198512-Feb-12 4:05
memberbigbro_198512-Feb-12 4:05 
GeneralMy vote of 4 Pin
theanil30-Jan-12 8:27
membertheanil30-Jan-12 8:27 
QuestionWhere is Microsoft.Ink? Pin
adrian lewis15-Sep-11 1:51
memberadrian lewis15-Sep-11 1:51 
AnswerRe: Where is Microsoft.Ink? Pin
bigbro_198515-Sep-11 2:29
memberbigbro_198515-Sep-11 2:29 
GeneralMy vote of 5 Pin
Mystcreater6-Jul-11 8:21
memberMystcreater6-Jul-11 8:21 
QuestionSignature Pin
LouLanada28-Jun-11 6:43
memberLouLanada28-Jun-11 6:43 
AnswerRe: Signature Pin
bigbro_198529-Jun-11 19:02
memberbigbro_198529-Jun-11 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161021.1 | Last Updated 23 Sep 2010
Article Copyright 2010 by bigbro_1985
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid