Email button pdf

Email button pdf

troyd1troyd1 Posts: 3Questions: 2Answers: 0

I would like to add a button to to the datatable buttons called Email which when clicked would prompt for an email address and then call the pdf creation like the pdf button does and then do an ajax call to the server with the pdf. On the server I would save the pdf and then email it. I know how to do the server side, but need help with creating a custom button, adding a prompt for the email ( I can do the prompt, just need a function call) and then then code to create the pdf and send it via ajax.

I think this could be super useful and have seen several request for things like this, but this implementation to me makes the most sense. I am just way over my head with how datatables works to implement this.

Answers

  • allanallan Posts: 48,908Questions: 1Answers: 7,131 Site admin

    Honestly, I'd suggest you generate the pdf on the server-side. Use buttons.exportData() to get the data to send and then have the server build the PDF. You get far more capable APIs for pdf generation and it will save a significant amount of bandwidth not including pdfmake in your Javascript.

    That said, you do want to do it, you could base your PDF generation of how Buttons does it and then instead of downloading it (lines 1422+) you would get the data from the blob and Ajax send it to the server to be saved as a file.

    Allan

  • troyd1troyd1 Posts: 3Questions: 2Answers: 0

    Allan, that is what I was looking for. On line 1426 where it does pdf.download( info.filename ), I could ajax the pdf. How do I reference the actual pdf? ie, pdf.value or is pdf the actual pdf?

Sign In or Register to comment.