Save HTML file as PDF

I have a project in which we have a web page with a button which we want to take an HTML file and save it as a PDF file. Is it possible to do this simply with JavaScript? If so, how do I do it? And if I can’t do this with JavaScript, does anyone know of another way to translate an HTML file to a PDF format?
Thanks in advance

I didn’t find the right solution from the internet.

Hi Thomas!

Creating a non-interactive PDF was answered in the link You provided so I’m assuming You need interactivity on your page (i.e. the button). You can do this with Adobe Acrobat Pro which is part of the Creative Cloud subscription. Acrobat can read the HTML straight out and then You can use the “Forms Editor” to add interactivity to the PDF, including the ability to write your own JavaScript - but there are many standard actions already done for You (e.g. “go to URL”).

If You are not a Creative Cloud member then search for PDF editors that can do interactive editing, as the stand alone cost for Acrobat is $$$.

BTW: I have not actually used this process for a job. I just now looked this topic up on the Internet. I am a Creative Cloud subscriber and gave the process I just described a quick trial on a basic HTML page and everything seems to work as advertised. This is the full limit of my expertise.

Who is pushing the button. Visitors or yourselves ?
Does the HTML change?.

If the page content is not dynamic then you could pre create the PDF and have it ready to save down afresh when the button is clicked.

There are various ways to create a PDF from HTML and Jim has posted one of them. There is also the built in methods on Browser.