javascript – Easiest way to generate a PDF from an HTML input, client-side

Question:

I'm developing teaching material in web language, and inside it, there are some exercises in which the user has to answer some questions, writing a brief dissertation inside a Text Area.

After finishing the exercise, I would like a PDF to be generated with this text he wrote, so that he can download it to his computer. As you can see, the solution can be client-side.

It doesn't need to be generated from scratch. In this case, I can develop a PDF template, already with style, fonts, colors, tags etc. and a field, which will be filled in by this user input.

I ask this question because the procedure is really quite simple, it's not a complete form, the PDF won't have multiple pages, the JavaScript won't necessarily need to style the PDF…

However, I can't find simple solutions, jsPDF seemed a bit complicated for my request…

Answer:

Aside from the jsPDF project , there's nothing else out there that suits your requirement to generate client-side PDFs.

I don't know why you find jsPDF complicated, after all, starting and ending a document is quite simple compared to more advanced server-side tools:

var doc = new jsPDF();                         // novo documento

doc.text("Bastante simples o jsPDF!", 35, 25); // algum texto

doc.save('verifica.pdf');                      // download
Scroll to Top