Knowledgebase: Developer
Convert HTML to PDF from Powershell Script
Posted by Craig Lebakken on 30 May 2018 11:30 AM

Question:
How can I convert an HTML to PDF from a script?

Answer:
The following PowerShell script uses Internet Explorer to render and convert an HTML file (http://www.win2pdf.com in the example) to PDF:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("http://www.win2pdf.com")
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.visible = $true
$ie.ExecWB(6,2)
Start-Sleep -second 3
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.quit()

The script only works if Win2PDF is set to the default printer.  To avoid the Win2PDF File Save pop-up, you can enable the auto-name feature.

(2 vote(s))
Helpful
Not helpful

Comments (0)

Copyright 2000-2018 © Dane Prairie Systems LLC. All Rights Reserved. About Us | Privacy Policy | PDF Blog | Site Map