I made a certificate generator for a training centre last year, but then I found out that the documents created were actually being converted to PDF manually. This was taking up way too much time so I threw together a quick script to find .docx files in the current folder, convert them all to .pdf and then remove the .docx files.
$documents_path = './'
$word_app = New-Object -ComObject Word.Application
# This filter will find .doc as well as .docx documents
Get-ChildItem -Path $documents_path -Filter *.doc? | ForEach-Object {
$document = $word_app.Documents.Open($_.FullName)
$pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf"
$document.SaveAs([ref] $pdf_filename, [ref] 17)
$document.Close()
}
rm *.docx
$word_app.Quit()