'Printing HTML to PDF through Out-Printer

I'm fairly new to PoSH. I've been trying to automate printing HTML files to PDF using Microsoft's Print to PDF printer. My approach has been to Get-Content <file> | Out-Printer -Name "Microsoft Print To PDF".

This generates a PDF file with my HTML file in plain text.

What I am trying to do, is to print the rendered file and preserve CSS to a PDF file - much like saving a website as a PDF file in a browser.

I have tried countless other options to no avail - any help is appreciated!

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source