admin管理员组

文章数量:1332345

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....

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....

Share Improve this question edited Feb 7, 2011 at 8:15 NicolaPasqui asked Feb 3, 2011 at 16:52 NicolaPasquiNicolaPasqui 1,1201 gold badge8 silver badges17 bronze badges 1
  • stackoverflow./questions/1648715/… something to read while you wait for other ments. – phill Commented Feb 3, 2011 at 16:56
Add a ment  | 

3 Answers 3

Reset to default 1

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

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

Hope this helps you.. Thanks

If you want to go from form data to PDF then one of the methods you could try is to take the submitted data, create a HTML document, and convert that document to PDF. You wouldn't necessarily need to send the HTML to the user (though you could) because you'd be using the HTML merely for formatting purposes. Push the HTML into a variable and then parse it through one of the many HTML to PDF converters.

本文标签: phpSave form results as PDFStack Overflow