cognidox / OfficeToPDF

A command line tool to convert Microsoft Office documents to PDFs
https://www.cognidox.com/
Other
616 stars 141 forks source link

When executing the script via PHP, it doesn't convert #95

Open ijohnson-TCR opened 1 year ago

ijohnson-TCR commented 1 year ago

With this command: exec('OfficeToPDF.exe {path}\TEST.docx {path}\TEST.pdf /verbose', $output); I get this value for $output:

Converting with Word converter
Object reference not set to an instance of an object.
Did not convert

And the file does not convert.

However, when running this command directly from CMD or powershell: OfficeToPDF.exe {path}\TEST.docx {path}\TEST.pdf /verbose It works perfectly. What am I doing wrong?

ijohnson-TCR commented 1 year ago

I would also like to mention, I have added OfficeToPDF.exe to my path, and I've also tried shell_exec() and system() commands which both give the same error.

norobi commented 1 year ago

Same issue here though I'm trying to use OfficeToPdf on a remote computer using Jenkins.

Works perfectly in local but I have the same error when remoting

guazontsubasa commented 10 months ago

I think some how you have to run officeToPdf like SYSTEM user. When you run it from console with your windows user it runs ok, no? When you run it from the web your System user is running the script. Try logging the user when you run it:

"Current user: " . get_current_user()

or

"Current user: " . exec('whoami')