cognidox / OfficeToPDF

A command line tool to convert Microsoft Office documents to PDFs
https://www.cognidox.com/
Other
609 stars 137 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 11 months 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 8 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')