brinley / jSignature

jQuery plugin for adding web signature functionality
http://www.unbolt.net/jSignature
696 stars 529 forks source link

Display signature again #101

Open DazornSama opened 8 years ago

DazornSama commented 8 years ago

Hi all, i have a c# asp net mvc application, that let users sign their documents. When i have to save the string, it works fine with hidden input and jquery code (i save the string in db):

var sig_data = $("#signature").jSignature("getData", "image"); var img = sig_data[1]; $("#firma-hidden").val(img);

But, i need to import the signature when the user want to modify his document. Actually i used this inline code:

<script src="~/Scripts/jSignature.js"></script> <script src="~/Scripts/crea-funzioni.js"></script> <script> $(document).ready(function () { $("#signature").jSignature("setData", 'data:image/jsignature;base64,@Model.FIRMA'); }); </script>

How can i get this work?? Here is an example of the string i got and i put in the db:

iVBORw0KGgoAAAANSUhEUgAAAWgAAABaCAYAAACVIMzHAAAZX0lEQVR4Xu1df5AdVZWeZCYOATYJMWKMupmsuAomkwSoFatQBi2oXcBFSiwXdmsZVpBa/AFYUoBlmURXEFeXZGuhxPxBUgUk1OKS1S1qV3crk1VK+AMy+SFRt9QHSiliYILBkJnJZL+vPed5X0/36x+vb79+752u6nrvdd8+99zv9vv69LnnnjunzzZDwBAwBAyBSiIwp5JamVKGgCFgCBgCfUbQdhMYAoaAIVBRBIygK9oxppYhYAgYAkbQdg8YAoaAIVBRBIygK9oxppYhYAgYAkbQdg8YAoaAIVBRBIygK9oxppYhYAgYAkbQdg8YAoaAIVBRBIygK9oxedUaHh5+99y5cxfMmTPnsMo4fvz4yfzuHuPvmZmZpceOHTuwf//+vXnrs+sMAUPAHwJG0P6w9Sp55cqVwwMDAytBxm8F8a4BCa/B5xA+ScQNdUcdcwvgfA2/x/C5f2pq6jvtJOy1a9eeR9127969yyuAJtwQ6AAEjKA7oJPWYOvv718tJLwGKo+QdHUjIevvtOTsXD8DOXPFwqac47CsF4+Pj0+0A5ozzzwzaNhTTz1l92Y7OsDqrBQC9ieoVHf8XpnVq1efC8v4ndjPxc8PqAUcJuWw6lms53BZl+DxfQMIcn3Z0Cg58yHz5JNP2r1Zdg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BjCzgUq/pjHlJyT0tcaQffanWPt7UkENNsdGy/T8ydk9ZvxXgOEbxUgSK5zOWsDma4BPosiTg3hGpJsw4aya3A8qnyQE8VNs+tYzOwDrshzTlL6WiPoXrs7rb09iwBIeiNI4gYQwyRAeA32Cfy+ExNZ9uHzMI4fSiKMVsGT1dsXppGTIrlaJGk6skfS1OM8tGYVdwk2rSyVF3PtvwPvjWlT7hpBZ0HdyhoCHY4ASDpIWgYyfhlNWcDm5CUhH1BEJd8K19NMX3Xh+NAti0zRYxqfj+E6vqXQz7wjawSNEXQW1K2sIdDhCMig4Y64zJJFE1zR8nzBzwx1MbJJrrOmycsU+lnH01rGadthBJ0WKStnCHQRAhIjfQeadEKVmgWi3BNFiCEdx5roTN96nF99wrcLp2gsjaCLRtTkGQIdjIAk6xkqsAnkREvUlBNQI+icwNllhoAhYAj4RuD/AVKU6C2Jv9KGAAAAAElFTkSuQmCC

brinley commented 8 years ago

It looks like you got your formats mixed up.

Try saving your data as $("#signature").jSignature("getData", "base30");

And reimporting as $("#signature").jSignature("setData", 'data:image/jsignature;base30,@Model.FIRMA');

DazornSama commented 8 years ago

Thanks @brinley !

DazornSama commented 8 years ago

I have another issue. Now i need to render the saved string to an image. How can i do this?? I use c# asp.net mvc

brinley commented 8 years ago

Try looking at the https://github.com/brinley/jSignature/tree/master/extras/SignatureDataConversion_dotNet

DazornSama commented 8 years ago

Yeah, i used them. I have this code: jSignature.Tools.Base30Converter Base30 = new jSignature.Tools.Base30Converter(); int[][][] arrBase30 = Base30.Base30ToNative(Rapportino.FIRMA); string strSVG = jSignature.Tools.SVGConverter.ToSVG(arrBase30); var byteArray = Encoding.ASCII.GetBytes(strSVG); using (MemoryStream stream = new MemoryStream(byteArray)) { var mySVG = SvgDocument.Open(stream.ToString()); var bitMap = mySVG.Draw(); bitMap.Save(HttpContext.Current.Server.MapPath("~/Pdf/Firme/" + IdTesta + ".png"), ImageFormat.Png); }

But the execution return this error: The specified document cannot be found. on: var mySVG = SvgDocument.Open(stream.ToString());

Where am i wrong?