Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output HTML form data to PDF?

Tags:

css

forms

pdf

I need to collect data from a visitor in an HTML form and then have them print a document with the appropriate fields pre-populated. They'll need to have a couple of signatures on the document, so it has to be printed.

The paper form already exists, so one idea was to scan it in, with nothing filled out, as an image. I would then have the HTML form data print out using CSS for positioning and using the blank scanned form as a background image.

A better option, I would think, would be to automatically generate the PDF with this data, but I'm not sure how to accomplish either.

Suggestions and ideas would be greatly appreciated! =)

like image 844
WebDevKev Avatar asked Feb 22 '12 21:02

WebDevKev


People also ask

How do you collect data from a form in HTML?

HTML Input Text<input type="text"> tag is used to collect the text from user. HTML name attribute is used to define the name or identity of the <input> element. HTML value attribute is used to define the initial value for an input field.


2 Answers

I would have to respectfully disagree with Osvaldo. Using CSS to align on a printed document would take ages to do efficiently in the aspect of cross-browser integration. Plus, if Microsoft comes out with a new browser, you're going to have to constantly update for the new use in browsers.

If you know any PHP (Which, if you know JavaScript and HTML, basic PHP is very simple), here's a good library you can use, FDPF:

Thankfully, PHP doesn't deprecate a whole lot of methods and the total code is less than 10 lines if you have to go in and change things around.

like image 154
Christopher Avatar answered Oct 15 '22 04:10

Christopher


You can control printed documents acceptably well with CSS, so I would suggest you to try that option first. Because it's easier.

like image 27
Osvaldo Avatar answered Oct 15 '22 05:10

Osvaldo