I'm using this code to draw on the screen https://github.com/szimek/signature_pad
How to save within the folder of the server the image created from the markings along with the background image.
Sample directory: /home4/host/public_html/testes/
var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
backgroundColor: 'rgba(255, 255, 255, 0)',
penColor: 'rgb(0, 0, 0)'
});
var saveButton = document.getElementById('save');
var cancelButton = document.getElementById('clear');
saveButton.addEventListener('click', function(event) {
var data = signaturePad.toDataURL('image/png');
// Send data to server instead...
window.open(data);
});
cancelButton.addEventListener('click', function(event) {
signaturePad.clear();
});
.wrapper {
position: relative;
width: 250px;
height: 367px;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
img {
position: absolute;
left: 0;
top: 0;
}
.signature-pad {
position: absolute;
left: 0;
top: 0;
width: 250px;
height: 367px;
}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/signature_pad.umd.min.js"></script>
<div class="wrapper">
<img src="http://www.hostcia.net/testes/html5Assinatura/Hatch.jpg" width=250 height=367 />
<canvas id="signature-pad" class="signature-pad" width=250 height=367></canvas>
</div>
<div>
<button id="save">Save</button>
<button id="clear">Clear</button>
</div>
Thank you.