Hello,
I have been trying to automate converting a bulk of HTML documents I have (powershell generated HTML documents) into a single .PDF document as a report.
I have been using wktmltopdf to start - and it works fine for the task, but I cannot seem to automate it (at least multiple-in, single-out).
The issue I’m having is outputting the selected files into the wkhtmltopdf cli as a “list”.
##Syntax for wkhtmltopdf = command ran from /bin of directory wkhtmltopdf [global option] [documents/HTML] [file output full path]
##powershell script that takes HTML document path names and converts them into single PDF file
$OutputFile = '$HOME\Documents\TempPDFReport\reporttest6.pdf'
$wkhtmltopdfRootDir = 'C:\Program Files\wkhtmltopdf\bin'
$GetChildItems = (Get-ChildItem -Path $HOME'\documents\TempHTMLConvert' -recurse |`
where {$_.extension -eq ".html"} |`
Select-Object -Property FullName).FullName -join ' '
&'c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe' $GetChildItems $OutputFile
What I expected here was that it would generate a list of all child items, join them with a space (The files and paths have no spaces in the names so no quotations needed), and act as a “list” of all the files to be input to the wkhtmltopdf.exe CLI, separated with a space.
I am however getting errors. When I add a Set-Clipboard pipe within the GetChildItems cmdlt and paste that into the wkhtmltopdf.exe CLI and add an output location - it works just fine. But the pass in the script doesn’t seem to function, it throws wkhtmltopdf.exe error “unknown protocol c”, which means it thinks that the first C in the first file path C:.… is a protocol, but I can’t figure out what in the output format is causing that. There is no space after the C:.
If anyone knows a good way of being able to “pipe” PowerShell objects into other CLI - I’d greatly appreciate the help. I’m not crazy good with powershell, so I’d imagine you can do an array or something, or maybe a more complex -join?
Thanks in advance,
-Mackling101