I made a feature for my website to let my users download the content of the site using these instructions: Printing with Javascript || Mozilla Dev. Basically the user is printing a new formated site stored in a hidden iframe. Now I want to let the user download that same PDF by clicking a button. Is there any easy way? I'm very happy with the result of window.print().
I've taken a look a jsPDF but it doesn't seem to be rendering my CSS correctly. Aditinally this library is pretty messy and hardly documented, I had to digg into the code, and I can't get it to work properly.
There's no way to do it reliably client-side. You could use PhantomJS or similar server-side to handle PDF generation.
If it were me, I'd just let the users do it themselves. Chrome, for example, has a virtual printer driver which exports as a PDF. For everyone else, there are print drivers available that do the same thing, such as CutePDF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With