Replies: 2   Views: 5045
Problems with transformdocument()
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by AndrewCooper  · 28-06-2016 - 10:50


I've got the following code.

$this->transform = new Phpdocx\Transform\TransformDocAdvLibreOffice();
    try { 
      $dest = "/OriginSystems/cache/application/Updraft/administrator/" . $uniqueReferenceID . ".pdf";
      error_log("FileName: " . $proc->getFileName());
      error_log("Destination: $dest");
        array("debug" => true)
    } catch (Exception $e) {

The resulting PHP log looks like this.

[28-Jun-2016 11:27:09 Africa/Johannesburg] FileName: /OriginSystems/cache/application/Updraft/administrator/10305949.docx
[28-Jun-2016 11:27:09 Africa/Johannesburg] Destination: /OriginSystems/cache/application/Updraft/administrator/10305949.pdf

As you can see, in this case I'm simply attempting to transform an existing Docx document into a PDF document. Nothing terribly fancy.

I'm using CentOS 7 as the server operating system and I've installed LibreOffice via Yum. My Phpdocx config file has the following in it.

; libreoffice or openoffice
method = "libreoffice"

; libreoffice installation path, absolute path
path = "/usr/bin/soffice"

The file, soffice, exists and works. However, when I run the PHP script I get the following error:

<Entry reference="REF_577242eed8076" TimeStamp="2016/06/28 11:27:10" Category="Exception" Type="Error"><![CDATA[

Description         rename(/OriginSystems/cache/application/Updraft/administrator/10305949.pdf,/OriginSystems/cache/application/Updraft/administrator/10305949.pdf): No such file or directory
File                /webdevroot/Updraft/web/internal/Library/docx/phpdocx/Classes/Phpdocx/Transform/
Line                140
Class               BasicException
Category            Warning
       8  /webdevroot/Updraft/web/internal/Library/Basics.php   541                                                     newFromError
       6  /webdevroot/Updraft/web/internal/Library/docx/phpdocx/Classes/Phpdocx/Transform/   140    rename
       5  /webdevroot/Updraft/web/internal/System/Common/LawDOCX.php   31                                               transformDocument
       4  /webdevroot/Updraft/web/internal/System/Administrator/AdmDraftOutputs.php   70                                __construct
       3  /webdevroot/Updraft/web/internal/System/Administrator/UIvalidate.php   506                                    __construct
       2  /webdevroot/Updraft/web/internal/Library/LibAjax.php   136                                                    generate
       1  /webdevroot/Updraft/web/external/System/Administrator/a.php   19                                              execute

UI                  Administration console
Customer            RGN001 - Origin Systems
User                Dev User    root   (50847)
Code                2
When                2016/06/28 11:27:10
     name                                              value                                             
     xbrF                                              v5ha8jfikg734j2cijfvv1adc3                        
     ccof                                              RGN001                                            
     ZDEDebuggerPresent                                php,phtml,php3                                    
Client IP 
URL called
Referred by


As you can see, the rename() command is failing because the file indicated in the first parameter doesn't exist. This is correct. I've checked afterwards and it doesn't exist.  When I run the transform command that is being sent to passthru() in the terminal as root, everything works quite well. When I run the same command as any other user I get a permissions error.

/usr/bin/soffice: line 56: cd: /root: Permission denied

This means (I think) that the PDF file isn't getting created in the first place due to permissions and so that the rename function bombs. I can't figure out what the permissions problem is though. Both the target and destination directories are usable by the web server. The Docx file is generated by Phpdocx and it is writing to that folder fine. I've also changed the tmp folder to the folder that the wev server has permissions to access as well.  Am I missing something with the permissions?  I did a straight install of LibreOffice. No weirdness at all.



Posted by AndrewCooper  · 29-06-2016 - 10:55

Thanks, admin!  I'll check that out.