I'm converting word files to pdf files using soffice (on windows with powershell).
Calling the following code works pretty well:
$soffice = "C:\Program Files (x86)\LibreOffice 5\program\soffice.exe"
& $soffice --convert-to pdf "c:\temp\somefile.docx" --headless --outdir c:\tempHowever, the command exits immediately, before the pdf is actually created.
Is there anyway to wait for completion, before returning to the prompt?
I fear that batching multiple conversion spawn dozen of process and saturates the computer.
1 Answer
I found the solution. I simply have to spawn the process using Start-Process specifying to wait for completion:
Start-Process -FilePath $soffice ` -ArgumentList "--convert-to pdf ""c:\temp\somefile.docx"" --headless --outdir c:\temp" ` -Wait