I've lost already 3 days googlin' and trying to sort this one out with no luck. I am unable to run an exec() command calling a .exe file to transform a generated .docx file to .pdf.
I've tried to use libreoffice, but I am unable to use it because of design loss in templates. I've tried to use other conversion libraries but the docx design loss is even worse.
The best way that works on the server is using PDFCreator's command line interface. The generated .pdf file is perfect. I have both MS Word and PDFCreator installed on the server machine.
In IIS I set everything to use the newly created "evpuser". The Application Pool the site is using is "evp", the Identity in Process model is "evpuser" with Load user profile set to true.
The evpuser, IIS_IUSRS and IUSR have full control right over the pdfcreator-cli.exe, over the PDFCreator folder in Program files and over the output folder, where the generated file would be.
In IIS Sites the anonymous authentication is enabled, with the same specified user.
When I tried to run with PHP exec(whoami) I get the result of SRV\evpuser. I even changed the user to administrator group.
When I try to run the command with a cmd.exe run as the evpuser:
"C:\\Program Files\\PDFCreator\\PDFCreator-cli.exe" PrintFile /File="C:\\inetpub\\evp\\storage\\app\\temp\\2024-03-04--22-39-37-802_1.3.docx"
i get the expected result, but when I try to run it with PHP:
$command = '"C:\\Program Files\\PDFCreator\\PDFCreator-cli.exe" PrintFile /File="C:\\inetpub\\evp\\storage\\app\\temp\\2024-03-04--22-39-37-802_1.3.docx"';
$out = array();
exec($command, $out,$exitcode);
echo "<br />EXEC: ( exitcode : $exitcode )";
dd($out);
nothing happens.
If i put the same command in a batch file and run the batch file on the server, the .pdf gets created. If I run the same batch file from the exec(), nothing happens.
Maybe I missed some privileges somewhere, but I tried everything read on the internet; the only solution I have not yet tried is to uninstall IIS and install Apache, which I would not like to do because of company instructions.
Is there any way I could debug this and see the reason why the command through exec() is not completing on the server?
Thank you