Brian, you rock !
I had to do the following to get it to work, since we were checking for this line included data:image/png;base64,
.
But with your help and some digging around i obtained a pdf with the signature on it :)
This is the code in case somebody needs it in the future.
the html part :
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="jquery.signaturepad.css" media="screen">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.signaturepad.min.js"></script>
</head>
<body>
<form method="post" action="pdf.php" class="sigPad">
<label for="name">Print your name</label>
<input type="text" name="name" id="name" class="name">
<p class="drawItDesc">Draw your signature</p>
<ul class="sigNav">
<li class="drawIt"><a href="#draw-it">Draw It</a></li>
<li class="clearButton"><a href="#clear">Clear</a></li>
</ul>
<div class="sig sigWrapper">
<canvas class="pad" width="198" height="55"></canvas>
<input type="hidden" name="imgOutput" class="imgOutput">
</div>
<button type="submit">I accept the terms of this agreement.</button>
</form>
<script>
var sig;
$(document).ready(function() {
/*sig = $('.sigPad').signaturePad();*/
sig = $('.sigPad').signaturePad({drawOnly:true});
});
$('.sigPad').submit(function(evt) {
$('.imgOutput').val( sig.getSignatureImage() );
});
</script>
</body>
</html>
pdf.php :
<?php
if(isset($_POST['imgOutput'])){$img_output = $_POST['imgOutput'];}
$bse = preg_replace('#^data:image/[^;]+;base64,#', '', $img_output );
if ( base64_encode( base64_decode($bse) ) === $bse ) {
require_once 'dompdf/dompdf_config.inc.php';
$html = '<!DOCTYPE html><html><head></head><body><p>Your signature:</p>
<br />
<img src="'. $img_output .'"></body></html>';
$dompdf = new DOMPDF;
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("test.pdf");
}
else {
echo ("ERROR !");
}
?>
Many thanks to @Thomas J Bradley, the dompdf team and @BrianS who saved the day.