ASP.NET + C# + TabletPC ActiveX Control + JavaScript = Base64 to GIF

K

Kunal

[Sorry for cross post- involves both C# and ASP.net - I desperately need help]

Hi all,

I have run into a problem that I can't quite figure out.

Here is the situation:

I have to capture a signature from a WebForm. (The ASP.NET application is running on a TabletPC)

Currently only an ActiveX control is available for WebForms, so I embedded it using the "<object>" tag.

I have a regular input button, that when clicked (onclick), triggers a Javascript function called SendInk

the SendInk Function is as follows:


function SendInk()
{
//Setup XML structure used to Capture Signature
var sBaseXML = "<Signature><Ink /></Signature>";

//Create XML dom object
var objXMLDOM = new ActiveXObject("Msxml.DOMDocument");

//set to wait for response and load structure
objXMLDOM.async = false;
objXMLDOM.loadXML(sBaseXML);

//Fill XML structure with Form Data;
objXMLDOM.selectSingleNode("/Signature/Ink").text = document.all.MSRSignature.Ink.Save(1);

//create XMLHttpobject
var objXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");

//Open Connection To Server
objXMLHTTP.open("POST","InkGetter.aspx",false);

//send XML to Server
objXMLHTTP.Send(objXMLDOM);

}

Pretty simple, and it works pretty well, I get the stream sent to the Page InkGetter.aspx.

The InputStream (Verified) is something like this:
<Signature>
<Ink>Base64:blahblahblahblah</Ink>
</Signature>

The Base64 string is the XML representation of the strokes on the ActiveX control where I signed my name. This is all well.

My PROBLEM is:

I want to reconstruct the image and save it as a GIF file. This is what I am doing on the Page_Load of InkGetter.aspx:

I Get the CORRECT Base64 string..HOW Do I get it convert it to a GIF and save it. [Have been trying for 1.5 days now :-( ]

public void Page_Load(object sender, System.EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Request.InputStream);
if (Request.InputStream != null)
{
BinaryWriter bw = new BinaryWriter(File.Create("C:\\CheckList\\MySignature.GIF"));

//path and filename is hardcoded now just while I am trying to get this working

bw.Write(Convert.FromBase64String(xmldoc.SelectSingleNode("//Ink").InnerText));
bw.Close();
}
}

The GIF File is created, but its empty..in WindowsForms this is trivial, but I have no other recourse except using the ActiveX control becoz of WEBFORM.

Can anyone see anything wrong with the Code under Page_Load??

HELP me Obi Wan Kenobi, You're my only hope :)

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top