Automate opening HTML and printing to PDF
Solution 1
http://code.google.com/p/wkhtmltopdf/
If internet explorer is not a requirement, this is kind of an older project, but I have used it with great success. It will allow you to specify a HTML page (On the internet or on your computer) from the command line and will automatically save it to a specified PDF file or even an image. Usage information is here. http://code.google.com/p/wkhtmltopdf/wiki/Usage
Solution 2
HTML-TO-PDF batch converts HTML documents to PDF. Makes use of Internet Explorer and ABCpdf, so the results should match what you expect to see in IE.
See: http://sourceforge.net/projects/html-to-pdf/
Related videos on Youtube
craigpatik
Updated on September 18, 2022Comments
-
craigpatik over 1 year
I need a way to automate the following process in Windows 7:
- Open an
.html
file in Internet Explorer - Print to PDF
- Save the PDF with a patterned file name (i.e.,
original_name_YYYY-MM-DD.pdf
)
Ideally, I could drag and drop several files or open a whole folder of files at once and a PDF would be created for each one. A command line solution is also acceptable.
The files have to be opened in the browser because parts of the page are rendered with JavaScript on page load. In other words, if you simply right-click on the file in Explorer and choose "print", the resulting file is not the same because the JS didn't run.
If it helps, Internet Explorer can be set as the default browser, and a PDF printer can be set as the default printer.
-
Ƭᴇcʜιᴇ007 almost 12 yearsWhat have you tried so far? Where are you getting stuck? Right now this is a list of wants, not a question. ;)
-
iglvzx almost 12 yearsIf you're adventurous enough, you can automate this task with AutoHotkey. I'll check back later and work this out if you haven't found a solution yet. :)
-
craigpatik almost 12 years@techie007: I am getting stuck because the converters I've found parse the HTML themselves and I need IE7 to parse it. iglvzx: Thanks, I will try that if affinefesh's suggestion doesn't pan out.
- Open an
-
iglvzx almost 12 yearsDoes it execute JavaScript in the process before printing? This is the main requirement for @craigpatik ...
-
iglvzx almost 12 yearsDoes it execute JavaScript in the process before printing? This is the main requirement for @craigpatik ...
-
DanielG almost 12 yearsIt does. It uses webkit so it is a full featured renderer.
-
AffineMesh almost 12 yearsYes. Note that documents are generated as soon as a page has finished loading and JavaScript animation with an initial blank state won't show up unless the rendering process is delayed.