ODT AS PDF Windows IIS Error

Hello, I have been struggling with the problem of converting ODT to PDF for several days.

Dolibarr 15.0.3 runs on windows and IIS
I have been setting it up according to the instructions below but it always ends up with an error.

his information can be useful for diagnostic purposes (you can set option $dolibarr_main_prod to '1' to hide sensitive information):
Datum: 20220922155051
Dolibarr: 15.0.3 - https://www.dolibarr.org
Úroveň vlastností: 0
PHP: 8.1.1
Server: Microsoft-IIS/10.0
OS: Windows NT SERVER-HP 10.0 build 19044 (Windows 10) AMD64
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

požadovaná adresa URL: /compta/facture/card.php?facid=4
Referer: https://cmr.mhweb.cz/compta/facture/card.php?facid=4
Manager nabídky: eldy_menu.php

Moduly/aplikace: user, facture, societe, fournisseur, adherent, expensereport, commande, contrat, ficheinter, expedition, paymentbybanktransfer, banque, product, service, bom, stock, productbatch, projet, agenda, ecm, categorie, fckeditor, barcode, workflow, import, export, notification, mailing, emailcollector, cron, clicktodial
Správce typu databáze: mysqli
Žádost o poslední přístup do databáze v případě chyby: Žádný chybný požadavek
Návratový kód pro přístup k databázi v případě chyby: Žádný chybný požadavek
Informace pro poslední přístup do databáze v případě chyby: Žádný chybný požadavek

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail (option MAIN_ODT_AS_PDF is libreoffice, command was soffice --headless "//C:\WebPage\cmr.mhweb.cz/documents/users/temp" --convert-to pdf --outdir "C:\WebPage\cmr.mhweb.cz/documents/facture/FA2209-0002" "C:\WebPage\cmr.mhweb.cz/documents/facture/FA2209-0002/FA2209-0002_test.odt", retval=-1073740791) :

If I use the command line the pdf is created without problems

Hello,

I don’t know if it is linked but Dolibarr V15 is NOT compatible PHP V8

Switched and tested to version 7.4.27 and the result is the same.

After several hours of searching I managed to solve the problem:

The problem was that IIS did not have access to the fold template
A line had to be replaced in the odf.php file:

$command ='soffice --headless -env:UserInstallation=file:"//'.$conf->user->dir_temp.'" --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);

za:

$command ='soffice -env:UserInstallation=file:///C:/test/NPP --headless --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);

I hope this guide will help someone in the future

I am attaching a link below
https://helpdesk.mhweb.cz/knowledgebase.php?article=29