0

I'm trying to play with SignaturePad - to capture a signature - the raw coding works - but it pops into a new browser and is sent as data:image/png;base64etc...

That is fine - but I'm trying to capture the data to a .cfm url - ie:signed.cfm?sigstr="data:image/png;base64etc..." - and then I can do things with it. Not having much luck with changing the url - and no new browser window - I'm thinking it is this code below...

window.open(signaturePad.toDataURL());

Any help is appreciated

 var wrapper = document.getElementById("signature-pad"),
clearButton = wrapper.querySelector("[data-action=clear]"),
saveButton = wrapper.querySelector("[data-action=save]"),
canvas = wrapper.querySelector("canvas"),
signaturePad;

 // Adjust canvas coordinate space taking into account pixel ratio,
 // to make it look crisp on mobile devices.
 // This also causes canvas to be cleared.
 function resizeCanvas() {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
var ratio =  Math.max(window.devicePixelRatio || 1, 1);
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
 }

 window.onresize = resizeCanvas;
 resizeCanvas();

 signaturePad = new SignaturePad(canvas);

 clearButton.addEventListener("click", function (event) {
signaturePad.clear();
 });

 saveButton.addEventListener("click", function (event) {
if (signaturePad.isEmpty()) {
    alert("Please provide signature first.");
} else {
    window.open(signaturePad.toDataURL());
}
 });
Merle_the_Pearl
  • 1,391
  • 3
  • 18
  • 25

0 Answers0