# output to HTML $data | # make sure you use Select-Object to copy the objects Select-Object-Property * | Convert-ArrayToStringList | ConvertTo-Html-Title Report -Head$stylesheet | Set-Content-Path$path-Encoding UTF8
Invoke-Item-Path$path
结果是位于 $Path 中指定的文件位置中的 HTML 报告。现在,缺少的是将 HTML 文件转换为 PDF 文件的方法。
if ($Chrome.Count -ne1) { throw"Chrome not installed." }
# compose destination path by changing file extension to PDF $destinationPath = [System.IO.Path]::ChangeExtension($Path, '.pdf')
# doing the conversion & $Chrome--headless--print-to-pdf="$destinationPath""$Path"
# (this is async so it may take a moment for the PDF to be created) do { Write-Host'.'-NoNewline Start-Sleep-Seconds1 } Until (Test-Path-Path$destinationPath)