Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Eiyad Ziyadah
19,250 PointsHow can I generate PDF from HTML form?
I want to use HTML form to collect data from user and let the user select one of two options: Option 1: print by laser printer. Option 2: print by dot-matrix printer.
I did some research to handle the options: for PDF & laser printing: I found PHP library to generate PDF. and for dot-matrix printing: I am thinking to use media print CSS to style the template.
Any ideas on how can I get the data from the form and print it? also Is there Javascript libraries to generate PDF?
1 Answer

Joseph Szoke
15,087 PointsThere are many ways to do this but my favorite is to use the .serialize() method. https://api.jquery.com/serialize/
This will put all of your form answers in a link string that can travel from page to page. Make it travel to a another page and then use JavaScript to split and break down the information how you want.
I know there are plugins that will convent pages to either print or make downloadable PDFs based off of your results page. Don't forget the print.css to keep things organized.
Hope this helps. Joe
Eiyad Ziyadah
19,250 PointsEiyad Ziyadah
19,250 PointsThanks Joseph,
Can you tell me what plug ins you know to do this?