1

我一直在研究这个问题一段时间,我有一个 Topaz 签名板,用于在用户使用我正在开发的应用程序时捕获他们的签名。我正在使用 Topaz 提供的标准演示应用程序来执行此操作(https://topazsystems.com/Software/sigplusnet_csharp_wpfsimpledemo.zip

我正在检索签名字符串,我可以将其保存到数据库(Microsoft SQL Server 2019);但是当我试图把它拉回来重建签名时,我不知道该怎么做。

我决定尝试“GetSigImage()”方法,但我也遇到了奇怪的错误见下文:

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());

我得到的错误是:

'Parameter is not valid.'

线上:

v = GetImage(sigPlusNET1.GetSigImage());

我的 GetImage() 方法是:

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;
        }
    }

我不确定我做错了什么或没有想到什么。任何人都可以提供的任何帮助将不胜感激

4

2 回答 2

0

在 Topaz 推出的另一个演示中找到了答案。想我会把它放在这里以防万一有人遇到同样的问题。

您必须先为图像设置参数,然后才能将其保存或检索为图像。我正在粘贴下面的代码。

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();
于 2021-11-03T02:11:19.110 回答
-1

这是我用来获取签名的内容

我在我们的软件中使用它来签署豁免,以允许成人和未成年人进入我们的设施。

然后它将签名应用到 PDF 文件上。

在此处输入图像描述

    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
于 2022-02-03T03:54:42.137 回答