cognidox / OfficeToPDF

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

Error when running through Jenkins #33

Closed graue70 closed 5 years ago

graue70 commented 5 years ago

When I run OfficeToPDF on the command line in Windows Server 2016 with Microsoft Office Professional Plus 2019 installed, everything works perfectly. If instead I let Jenkins run the same command on the same machine, I get the following message: 'Object reference not set to an instance of an object.' The task manager shows the process 'Microsoft Word' with 51% CPU load. It runs indefinitely and I need to stop it manually. It then adds 'Did not convert' to the output.

I tried the versions 1.3.0.0, 1.8.0.0 and 1.8.22.0 which show equal behaviour.

Can you tell me what's going on? What is the difference between me running the command and Jenkins running the command?

These seem to be similar problems, but there is no solution mentioned: https://stackoverflow.com/questions/24860351/object-reference-not-set-to-an-instance-of-an-object-did-not-convert https://stackoverflow.com/questions/11796414/convert-ms-office-to-pdf/11796615

vittala commented 5 years ago

Could be a permission issue. Is Jenkins running as a service?

It's possible the user Jenkins is running under doesn't have sufficient permissions to properly run Word. Have a look at https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/742e4b7c-594d-4c10-8bae-f8d398d0e190/windows-service-running-word-via-dcom?forum=windowscompatibility#ec7bea31-4d88-4128-b09d-4cf40421d545 for some suggestions, namely:

Regards Vittal

graue70 commented 5 years ago

I could not change the DCOM permissions because “HKEY_CLASSES_ROOT\AppID\WINWORD.EXE” does not exist.

Before, I had already tried fixing the problem by creating "C:\Windows\SysWOW64\config\systemprofile\Desktop". I thought this was the correct location because it is a 64 bit system. However, this reasoning seems to be wrong, because creating "C:\Windows\System32\config\systemprofile\Desktop" did indeed fix the problem. The directory at the "SysWOW64" location is not even necessary.

Problem solved. Thank you for your help.