I have tried a script which save canvas as png but I want to save it as pdf. I tried many scripts but not working for me. The script od saving png:
// Initializing
window.onload = function(){
var dwn = document.getElementById('btndownload'),
canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
// Drawing a circle
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var radius = 70;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'rgba(0,200,0, .7)';
context.fill();
context.lineWidth = 2;
context.strokeStyle = 'black';
context.stroke();
// Drawing a rect
context.beginPath();
context.rect(15, 50, 100, 100);
context.fillStyle = 'rgba(255,255,0, .7)';
context.fill();
context.lineWidth = 2;
context.strokeStyle = 'black';
context.stroke();
// Event handler for download
dwn.onclick = function(){
download(canvas, 'myimage.png');
}
}