Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript 'Print' button straight to 'Save as PDF' [closed]

I want to implement a button that will allow users to save a pdf copy of an html page. I know they can go through the 'print' interface, and select the 'save as pdf' option, but I'd rather have my button automatically select that option so that it automatically selects the option 'save as pdf' (or better yet, goes straight to the pdf download).

Is there a way to do this in javascript?

like image 565
Joshua Soileau Avatar asked Feb 16 '23 15:02

Joshua Soileau


1 Answers

The "Save to PDF" button in the print dialog doesn't exist in Windows afaik. Anyway, there's no way you can do this with Javascript.

If you really want to give your visitors a PDF download of your page, you need to render that PDF on the server side and link the button to the PDF file.

like image 198
Oskar Hane Avatar answered Feb 18 '23 10:02

Oskar Hane