I have created a function to take screenshot of current webpage and save it as PDF using html2canvas and jsPDF. Following is my code for it:
<script>
function downloadpdf(){
html2canvas(document.body,
{
onrendered: function(canvas){
var imgData = canvas.toDataURL("image/jpeg");
var a = document.createElement('a');
var doc = new jsPDF('p','mm');
doc.addImage(imgData, 'JPEG', 15, 40, 180, 160);
doc.save($.now()+'.pdf');
}
});
}
</script>
By using the above code, I am able to download the file and save it locally.
But I want to directly send the generated pdf by email using php script.
Following is the code for posting image in php script where it will be sent as email:
var imgData = canvas.toDataURL("image/jpeg");
$.post("sendimage.php",
{
data: imgData
}, function (response,status) {
console.log(response);
});
But how to post the generated pdf in data
parameter?
Kindly, recommend any solution for this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…