brinley / jSignature

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

Saving to Server C# .Net #89

Closed warrenla closed 9 years ago

warrenla commented 9 years ago

I am fairly sure this is not an issue, but I am finding the documentation a bit confusing on how to take the output of the jSignature and work with it on the server.

I have the data being passed to my server via a simple webmethod. Here I grab the string and do a bit of work with it. Unfortunately, the reporting tool we use does not support SVG format so I must convert it to a jpeg, gif, png or such...

Here is an exmaple of the code [WebMethod(EnableSession = true)] public int SaveSignature(string entityUID, string entityTypeUID, string sig) { var SaveSignature = sig;

        string[] image = SaveSignature.Split(Convert.ToChar(","));
        SaveImage(image[1]);

        return -1;

    }

public void SaveImage(string base64) {

        byte[] bytes = Convert.FromBase64String(base64);

        Image image;
        using (MemoryStream ms = new MemoryStream(bytes))
        {
            image = Image.FromStream(ms);
        }
        var filePath = "D:\\SourceControl\\Hayes IT\\NEXT\\TIPWebITApp\\TIPWebIT\\Attachment\\" + "ImageName.jpg";
        image.Save(filePath, System.Drawing.Imaging.ImageFormat.Gif);

    }

I get a parameter missing from the Image.FromStream method.. Here is the SVG data from jsignature: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iNTAxIiBoZWlnaHQ9IjEzMyI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0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tNyA2IGMgLTcuNiA4LjM4IC0xNC40IDE3LjIzIC0yMiAyNiBjIC0xLjI2IDEuNDYgLTIuNTYgMi44OCAtNCA0IGMgLTEuNDkgMS4xNiAtMy42NCAxLjc3IC01IDMgYyAtMi4xNCAxLjk1IC0zLjg2IDUuMDUgLTYgNyBjIC0xLjM2IDEuMjMgLTMuNjUgMS43MiAtNSAzIGMgLTQuNzUgNC41IC05LjggMTAuMDEgLTE0IDE1IGMgLTAuOTIgMS4wOSAtMS4wNCAzLjE0IC0yIDQgbCAtOCA1Ii8+PC9zdmc+

warrenla commented 9 years ago

Resolved

saeedht commented 7 years ago

Hi Warrenla,

I am facing the same issue. Can you please let me know how did you resolve? The JSignature is storing image data in base64 & base30 and I need to convert this back to image file so that I could pass that in crystal reporting.

Any help regarding this would be highly appreciated. Thank you.