I have a requirement to have a small script on a Windows Server using PowerShell to convert files to PDF (from RTF). I've got a prototype using Word that works on my desktop machine, but the servers involved don't have Office/Word installed. Is there a similar way I can call Wordpad to achieve the same thing?
$documents_path = 'c:\projects\pbl\hi.rtf'
$word_app = New-Object -ComObject Word.Application
$document = $word_app.Documents.Open($documents_path)
$pdf_filename = 'c:\projects\pbl\hi.pdf'
$document.SaveAs([ref] $pdf_filename, [ref] 17)
$document.Close()
$word_app.Quit()
You would not be able to accomplish this goal using only WordPad because it has no automation interface like Microsoft Word has. You would need to investigate an alternative solution to achieve this.