Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save form results as PDF

Tricky question.

I have a very long form where the user writes down a lot of data. I need to save the form for future reading (pdf, html, or even a jpg will do), but I need to save it with the data that the user wrote down. This has to be done on submitting the form.

I know it's going to be impossible with only PHP, but would it be possible with a little help from javascript-ajax?

I can't prompt the user to print the page, and I need to save the view without any other input from the user (beside the submit).

Any ideas?

EDIT:

in a nutshell,

is it possible to generate a pdf from that page without submitting the data ? is there a way fpdf (or others) could "read" and save what's currently on the screen, just like a "print" function ?

imagine a long, looong form, with a button "save as pdf" who saves the current page (with the data inputted from the user) WITHOUT submitting the form....

like image 491
NicolaPasqui Avatar asked Nov 06 '22 03:11

NicolaPasqui


2 Answers

Take a look at the thread: Which is the best PDF library for PHP?

Highested listed solutions include:

  • TCPDF
  • FPDF

Another possible solution would be converting HTML to PDF in PHP: HTML to PDF in PHP

like image 175
calvinf Avatar answered Nov 09 '22 15:11

calvinf


You can have a look at: http://php.net/manual/en/book.pdf.php and this http://www.tcpdf.org/

Hope this helps you.. Thanks

like image 31
Chetan Sharma Avatar answered Nov 09 '22 16:11

Chetan Sharma