public void sign() { SigCtl sigCtl = new SigCtl(); sigCtl.Licence = Properties.Settings.Default.License; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, name, reason, null, null); if (res == DynamicCaptureResult.DynCaptOK) { SigObj sigObj = (SigObj)sigCtl.Signature; //sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = System.IO.Path.GetTempFileName(); try { sigObj.RenderBitmap(filename, 400, 200, "image/png", 0.5f, 0xff0000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData | RBFlags.RenderBackgroundTransparent); } catch (Exception ex) { MessageBox.Show(ex.Message); } string newFile = InsertSignatureImageToPdf(filename); loadPdf(newFile, false); //getSignatureFromPdf(signedPdf); } }
public static void Capture(Tablet tablet) { SigCtl sigCtl = new SigCtl(); sigCtl.Licence = Common.TabletKey(); sigCtl.BackColor = 12; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, tablet.Who, tablet.Why, tablet.What, null); if (res == DynamicCaptureResult.DynCaptOK) { SigObj sigObj = (SigObj)sigCtl.Signature; String filename = tablet.SaveSignnamePicPath; try { sigObj.RenderBitmap(filename, 150, 100, "image/png", 2.0f, 0x00000000, 0x00FFFFFF, 0, 0, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); SignnameResult.Msg = ""; SignnameResult.Signnamed = true; } catch (Exception ex) { SignnameResult.Msg = ex.Message; } } else { SignnameResult.Signnamed = false; SignnameResult.Msg = ""; } if (res == DynamicCaptureResult.DynCaptNotLicensed) { SignnameResult.Msg = "签字版连接故障!请检查签字版是否已经正确连接!"; } }
private void btnSign_Click(object sender, EventArgs e) { print("btnSign was pressed"); DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "sig1.png"; sigObj.RenderBitmap(filename, 200, 150, "image/png", 0.5f, 0xff0000, 0xffffff, -1.0f, -1.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderBackgroundTransparent | RBFlags.RenderColorAntiAlias | RBFlags.RenderEncodeData); sigImage.Load(filename); } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
private void button1_Click(object sender, EventArgs e) { SigCtl sigCtl = new SigCtl(); sigCtl.Licence = "AgAZAPZTkH0EBVdhY29tClNESyBTYW1wbGUBAoECA2UA"; sigCtl.BackColor = 12; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "老年人健康体检 ", " 姓名:赵玉滨 性别:男 年龄:75\r\n 身份证号:370725198311181976\r\n 地址:潍坊市昌乐县乔官镇赵家淳于村", "what", null); if (res == DynamicCaptureResult.DynCaptOK) { //print("signature captured successfully"); SigObj sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "sig1.png"; try { sigObj.RenderBitmap(filename, 280, 120, "image/png", 2.5f, 0x000000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { Bitmap bmp = new Bitmap(filename); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); byte[] arr = new byte[ms.Length]; ms.Position = 0; ms.Read(arr, 0, (int)ms.Length); ms.Close(); sigImage.Image = System.Drawing.Image.FromStream(fs); fs.Close(); String strbaser64 = Convert.ToBase64String(arr); textBox_singtext.Text = strbaser64; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { //print("Signature capture error res=" + (int)res + " ( " + res + " )"); //switch (res) //{ // case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; // case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; // case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; // default: print("Unexpected error code "); break; //} } }
private void btnSign_Click(object sender, EventArgs e) { print("btnSign was pressed"); DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "sig1.png"; if (RenderSignatureAutoSize(filename, 100, 50) == false) { print("Too much signature data, please sign again"); return; } try { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { sigImage.Image = System.Drawing.Image.FromStream(fs); fs.Close(); } // sigImage.Load(filename); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
private void btnSign_Click(object sender, RoutedEventArgs e) { print("btnSign was pressed"); SigCtl sigCtl = new SigCtl(); sigCtl.Licence = "<<license>>"; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); SigObj sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "D:\\temp\\sig1.png"; try { //print("Saving signature to file " + filename); sigObj.RenderBitmap(filename, 200, 150, "image/png", 0.5f, 0xff0000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); print("Loading image from " + filename); BitmapImage src = new BitmapImage(); src.BeginInit(); src.UriSource = new Uri(filename, UriKind.Absolute); src.EndInit(); imgSig.Source = src; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
private void btnSign_Click(object sender, EventArgs e) { print("btnSign was pressed"); DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); try { byte[] binaryData = sigObj.RenderBitmap("", 200, 150, "image/png", 0.5f, 0xff0000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputBinary | RBFlags.RenderColor32BPP) as byte[]; using (MemoryStream memStream = new MemoryStream(binaryData)) { System.Drawing.Image newImage = System.Drawing.Image.FromStream(memStream); sigImage.Image = newImage; // work with image here. // You'll need to keep the MemoryStream open for // as long as you want to work with your new image. memStream.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
private void btnSign_Click(object sender, EventArgs e) { print("btnSign was pressed"); SigCtl sigCtl = new SigCtl(); sigCtl.Licence = "<<license>>"; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); SigObj sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "sig1.png"; try { sigObj.RenderBitmap(filename, 200, 150, "image/png", 0.5f, 0xff0000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { sigImage.Image = System.Drawing.Image.FromStream(fs); fs.Close(); } // sigImage.Load(filename); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
private void captureSig() { print("btnSign was pressed"); SigCtl sigCtl = new SigCtl(); sigCtl.Licence = "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI3YmM5Y2IxYWIxMGE0NmUxODI2N2E5MTJkYTA2ZTI3NiIsImV4cCI6MjE0NzQ4MzY0NywiaWF0IjoxNTYwOTUwMjcyLCJyaWdodHMiOlsiU0lHX1NES19DT1JFIiwiU0lHQ0FQVFhfQUNDRVNTIl0sImRldmljZXMiOlsiV0FDT01fQU5ZIl0sInR5cGUiOiJwcm9kIiwibGljX25hbWUiOiJTaWduYXR1cmUgU0RLIiwid2Fjb21faWQiOiI3YmM5Y2IxYWIxMGE0NmUxODI2N2E5MTJkYTA2ZTI3NiIsImxpY191aWQiOiJiODUyM2ViYi0xOGI3LTQ3OGEtYTlkZS04NDlmZTIyNmIwMDIiLCJhcHBzX3dpbmRvd3MiOltdLCJhcHBzX2lvcyI6W10sImFwcHNfYW5kcm9pZCI6W10sIm1hY2hpbmVfaWRzIjpbXX0.ONy3iYQ7lC6rQhou7rz4iJT_OJ20087gWz7GtCgYX3uNtKjmnEaNuP3QkjgxOK_vgOrTdwzD-nm-ysiTDs2GcPlOdUPErSp_bcX8kFBZVmGLyJtmeInAW6HuSp2-57ngoGFivTH_l1kkQ1KMvzDKHJbRglsPpd4nVHhx9WkvqczXyogldygvl0LRidyPOsS5H2GYmaPiyIp9In6meqeNQ1n9zkxSHo7B11mp_WXJXl0k1pek7py8XYCedCNW5qnLi4UCNlfTd6Mk9qz31arsiWsesPeR9PN121LBJtiPi023yQU8mgb9piw_a-ccciviJuNsEuRDN3sGnqONG3dMSA"; DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Who", "Why", null, null); if (res == DynamicCaptureResult.DynCaptOK) { print("signature captured successfully"); SigObj sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); String filename = "sig1.png"; try { sigObj.RenderBitmap(filename, 200, 150, "image/png", 0.5f, 0xff0000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { sigImage.Image = System.Drawing.Image.FromStream(fs); fs.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { print("Signature capture error res=" + (int)res + " ( " + res + " )"); switch (res) { case DynamicCaptureResult.DynCaptCancel: print("signature cancelled"); break; case DynamicCaptureResult.DynCaptError: print("no capture service available"); break; case DynamicCaptureResult.DynCaptPadError: print("signing device error"); break; default: print("Unexpected error code "); break; } } }
public static void MuestraFirmadora(String UrlFirma, int Width, int Heigth) { SigCtl sigCtl = new SigCtl(); DynamicCapture dc = new DynamicCaptureClass(); DynamicCaptureResult res = dc.Capture(sigCtl, "Name of the person", "Title", null, null); if (res == DynamicCaptureResult.DynCaptOK) { SigObj sigObj = (SigObj)sigCtl.Signature; sigObj.set_ExtraData("AdditionalData", "C# test: Additional data"); try { // Establecer url de salida de la imagen, el ancho, el alto, formato, e incluso grosor de pluma y color... sigObj.RenderBitmap(UrlFirma, Width, Heigth, "image/png", 0.5f, 0x000000, 0xffffff, 10.0f, 10.0f, RBFlags.RenderOutputFilename | RBFlags.RenderColor32BPP | RBFlags.RenderEncodeData); SignedDone(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (res == DynamicCaptureResult.DynCaptPadError) { MessageBox.Show("No dispones de una tableta firmadora conectada al sistema."); } else { if (res != DynamicCaptureResult.DynCaptCancel) { MessageBox.Show("Ha ocurrido un error al conectarse a la firmadora."); } } }