Sending a html form via email as a pdf
I have made an html form. What i want to happen is when the user clicks submit for the page to be emailed as a pdf (like the pdf that comes up if you print the webpage). I've been looking a all sorts of script b开发者_高级运维ut nothing seems to do what I want.
You will have to have a server-side component that takes the values, creates the PDF, and then e-mails it appropriately.
You'll be surprised to hear that not all browsers can easily make pdfs out of web pages. Hence, there is no universal JavaScript command that simply taps into a browser's capabilities. That leaves you with options:
- Generate the pdf on the server (using, say, pdfbox, and send the email right from the server (using good old sendmail).
- Generate the pdf on the server, have the user download it, and then transfer it all to his email client. (Might just work, see on Stackoverflow).
- Generate the PDF in the browser, cross-platform. There are some Javascript-only libraries that can generate PDF.
- Use Safari's PDF capabilities. Safari can make PDFs just in the print dialog. Explain that to your users and call
window.print()
.
精彩评论