HTML to PDF with client side JavaScript

I knew PDF viewing is hard, hence the excellent pdf.js library. I didn’t know converting HTML to PDF on client side is also hard.

Converting HTML to PDF on the server side is not bad. You could use wkhtmltopdf or PhantomJS. There is even a blog post with benchmarks.

There are few choices on the client side. One is HTML -> canvas -> image -> PDF. You can create PDFs with jsPDF or pdfkit, but you would have to render the HTML yourself and feed it to jsPDF/pdfkit…