1

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 but nothing seems to do what I want.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
dan
  • 11
  • 1
  • 2
  • possible duplicate of http://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net – Manatherin Jul 27 '11 at 13:18
  • @Manatherin - how did you get .net from this question? – Daniel A. White Jul 27 '11 at 13:19
  • @Daniel Im not sure i did, the top rated answer on that has a comment saying it is a standalone executable. You can launch it as a process, passing a URL of the HTML document as argument. a few of the other answers e.g. the one from stuart suggest non .NET examples – Manatherin Jul 27 '11 at 13:33

2 Answers2

2

You will have to have a server-side component that takes the values, creates the PDF, and then e-mails it appropriately.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
1

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:

  1. Generate the pdf on the server (using, say, pdfbox, and send the email right from the server (using good old sendmail).
  2. 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).
  3. Generate the PDF in the browser, cross-platform. There are some Javascript-only libraries that can generate PDF.
  4. Use Safari's PDF capabilities. Safari can make PDFs just in the print dialog. Explain that to your users and call window.print().
Community
  • 1
  • 1
nes1983
  • 15,209
  • 4
  • 44
  • 64