Jon
Jon

Reputation: 61

Problems retrieving signature using Topaz Systems Signature Pad

I've been working on this problem for a while, I have a Topaz Signature Pad I'm using to capture signatures from users as they use the application I'm currently developing. I'm using the standard demo app that Topaz supplies to do this (https://topazsystems.com/Software/sigplusnet_csharp_wpfsimpledemo.zip)

I'm retrieving the signature string ok, I can save it to the database (Microsoft SQL Server 2019); but when I try to pull it back out to reconstruct the signature I can't figure out how to do it.

I decided to try the 'GetSigImage()' method, but I get weird errors with that too See below:

public ImageSource v;

sigPlusNET1.SetTabletState(0);

// Encrypt the signature.
sigPlusNET1.AutoKeyStart();
sigPlusNET1.SetAutoKeyData("123");
sigPlusNET1.AutoKeyFinish();
//sigPlusNET1.SetEncryptionMode(2);

//sigPlusNET1.SetSigCompressionMode(1);

// This is the Topaz format SigString that can be stored for future use.
v = GetImage(sigPlusNET1.GetSigImage());

the error I get is:

'Parameter is not valid.'

on the line of:

v = GetImage(sigPlusNET1.GetSigImage());

My GetImage() Method is:

private ImageSource GetImage(Image source)
    {
        using (var ms = new MemoryStream())
        {
            source.Save(ms, ImageFormat.Bmp);
            ms.Seek(0, SeekOrigin.Begin);

            var bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.StreamSource = ms;
            bitmapImage.EndInit();

            return bitmapImage;
        }
    }

I'm not sure what I'm doing wrong or not thinking of. Any help anyone can offer would be greatly appreciated

Upvotes: 2

Views: 1779

Answers (2)

robinhood1995
robinhood1995

Reputation: 45

Here is what I use to get the signature

I used this in our software to sign for waivers to allow adults and minors into our facility.

Then it applies the signature onto a PDF file.

enter image description here

    Imports System.ComponentModel
    Imports log4net
    Imports log4net.Config
    
    Imports iTextSharp.text
    Imports iTextSharp.text.pdf
    
    Public Class frmSignatureTopaz
        Implements IDisposable
    
        Private Shared ReadOnly _log As ILog = LogManager.GetLogger(GetType(frmAllocateUser))
    
        Public frmclosedX As Boolean = True
        Public bolAdult As Boolean = True
        Public bolMinor As Boolean = False
    
        Private Sub frmSignature_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
    
                If bolMinor = True Then
                    GroupBox2.Enabled = True
                Else
                    GroupBox2.Enabled = False
                End If
    
    
            Catch ex As Exception
                _log.Error(ex.ToString & vbCrLf & ex.StackTrace.ToString)
                MessageBox.Show(ex.ToString, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Finally
                Me.Invalidate()
    
            End Try
        End Sub
    
        Private Sub cmdSign1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSign1.Click
            SigPlusNET2.SetTabletState(0)
            SigPlusNET1.SetTabletState(1)
        End Sub
    
        Private Sub cmdClear1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear1.Click
            SigPlusNET1.ClearTablet()
        End Sub
    
        Private Sub cmdSign2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSign2.Click
            SigPlusNET1.SetTabletState(0)
            SigPlusNET2.SetTabletState(1)
        End Sub
    
        Private Sub cmdClear2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear2.Click
            SigPlusNET2.ClearTablet()
        End Sub
    
        Public Sub cmdPlaceSigs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlaceSigs.Click
            If SigPlusNET1.NumberOfTabletPoints() = 0 AndAlso bolAdult = True Or SigPlusNET2.NumberOfTabletPoints() = 0 AndAlso bolMinor = True Then
                'User must sign first!!
            Else
    
                'Set from close to false as user add button was clicked
                frmclosedX = False
    
                SigPlusNET1.SetTabletState(0)
                SigPlusNET2.SetTabletState(0)
    
                'Image one
                SigPlusNET1.SetImageXSize(1000)
                SigPlusNET1.SetImageYSize(300)
                SigPlusNET1.SetJustifyY(10)
                SigPlusNET1.SetJustifyX(10)
                SigPlusNET1.SetJustifyMode(5)
                SigPlusNET1.SetImagePenWidth(10)
                SigPlusNET1.SetImageFileFormat(4)
    
                'Image two
                SigPlusNET2.SetImageXSize(1000)
                SigPlusNET2.SetImageYSize(300)
                SigPlusNET2.SetJustifyY(10)
                SigPlusNET2.SetJustifyX(10)
                SigPlusNET2.SetJustifyMode(5)
                SigPlusNET2.SetImagePenWidth(10)
                SigPlusNET2.SetImageFileFormat(4)
    
                Close()
    
            End If
        End Sub
    
    #Region " Closing "
        Private Sub frmSignature_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
            Try
                ' Check default of True for form close
                If frmclosedX = True Then
                    ' Leave boolean as is to close the form
                Else
                    ' Change the value to false to contiune on user add to bay allocations
                    frmclosedX = False
                End If
    
            Catch ex As Exception
                _log.Error(ex.ToString & vbCrLf & ex.StackTrace.ToString)
                MessageBox.Show(ex.ToString, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Finally
                Me.Validate()
                'Dispose(True)
                GC.SuppressFinalize(Me)
                GC.Collect()
                GC.WaitForPendingFinalizers()
    
            End Try
        End Sub
    #End Region
    
    End Class

Upvotes: -1

Jon
Jon

Reputation: 61

Found the answer in another demo that Topaz put out. Figured I'd put it here just in case anyone has the same problem.

You have to set parameters for the image before you can save or retrieve it as an image. I'm pasting the code below.

sigPlusNET1.SetImageXSize(1000);
sigPlusNET1.SetImageYSize(300);
sigPlusNET1.SetJustifyY(10);
sigPlusNET1.SetJustifyX(10);
sigPlusNET1.SetJustifyMode(5);
sigPlusNET1.SetImagePenWidth(10);
sigPlusNET1.SetImageFileFormat(4); //0=bmp, 4=jpg, 6=tif
sigimage = sigPlusNET1.GetSigImage();

Upvotes: 1

Related Questions