While using browsers like Chrome and Firefox, there is an option to print the page to PDF (that is saving the webpage as a PDF file).
<a href="JavaScript:window.print();">Print this page</a>
This code opens up the print page from where the user should manually choose print to PDF. Can this be done automatically? If so please help.
Yes… provided that your users have a few things installed.
Then, using the API of said plugin, you can choose which driver to print to. You can even skip the print dialog.
A better option, however, would be the generate the PDF server-side, stream it to them, and then use JavaScript inside the PDF to automatically open the print dialog as soon as they view it. This way they don’t need any plugins.