by using the below jquery code, I could able to download the canvas image as pdf.
<script>
jQuery(document).ready(function () {
html2canvas(jQuery("#abc"), {
onrendered: function(canvas) {
theCanvas = canvas;
document.body.appendChild(canvas);
// Convert and download as image
Canvas2Image.saveAsPNG(canvas);
jQuery("#img-out").append(canvas);
// Clean up
//document.body.removeChild(canvas);
}
});
});
</script>
<script>
jQuery(document).ready(function () {
jQuery('#btnSave').click(function() {
html2canvas(jQuery("canvas"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'mm');
doc.addImage(imgData, 'PNG', 37, 10);
doc.save('test.pdf');
}
});
});
});
</script>
But I also want to send this generated pdf file via email directly by using the below php script.
<?php
$to= 'test@gmail.com' . ',';
$to .= 'testamjadm61@gmail.com';
$sub='test1';
$msg= <<<EOF
<html>
<body>
Pls find the atteached pdf file.
</body>
</html>
EOF;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: <centos_test@example.com>' . "\r\n";
?>
Is it possible to attach a file by using this script? If so, could you pls tell me how to do that? If don't, pls tell me another alternative ways to do the same.
Pls note: I want all the php and the jquery in a single php file including the email function.