1

I have an HTML page with some input. When the customer clicks on Send button the below converted pdf has tobe sent in mail directly in php??Is it can be done?? If yes,how it can be done can someone help me in this flow

<script>
$('#print-btn').click(()=>{
var pdf = new jsPDF('p','pt','a4');
pdf.addHTML($('#divName')[0],function() {
pdf.save('billing.pdf');
});
});   
</script>
user5370838
  • 111
  • 2
  • 14
  • See [this link](https://stackoverflow.com/questions/30918682/how-to-upload-pdf-to-server-from-ajax-data-send-using-jspdf), the pdf file will be upload into your server, then you just need to attach that pdf in your email. – Van Tho Nov 16 '18 at 09:12

1 Answers1

1

As far as I know jsPDF only let you create a PDF on the client side of your application/website.

If you want to attach the generated PDF to an email you first have to pass the file created to a PHP script on your server side and then send the file like a normal attachment.

To pass the file you can encode your file in base64 and pass it as a string using AJAX to a PHP page where you will decode the data and generate the file with the content received.

After that you can attach it to an email and send it. The process here depends on what is your system of choiche for sending emails.

Another approach is to generate the file directly on the server side of your application/website so you can skip the js to php step.

Andrea
  • 328
  • 1
  • 6
  • 17