Forum


Replies: 3   Views: 3864
Target path ignored when using 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 lewisrblack  · 16-04-2015 - 14:08

When using the transformDocument method, the target path seems to be ignored, and the converted file is always stored in my web root. My code is as follows. $docx = new CreateDocx(); $docx->enableCompatibilityMode(); $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit'; $docx->addText($text, $paramsText); $docx->createDocx(DOC_DIR . '/test.docx'); $docx->transformDocument(DOC_DIR . '/test.docx', DOC_DIR . '/test .pdf'); The test.docx is created in the correct directory, but then the converted PDF is saved in the wrong directory. The output from the debugger is; convert /Library/WebServer/Documents/my_website/docs/test.docx -> /Library/WebServer/Documents/my_website/test.pdf using filter : writer_pdf_Export As you will see it has created the docx in /my_website/docs/ but the converted pdf is saved in /my_website Any suggestions would be welcome as to why the converted file is being saved in the wrong directory. Thanks, Lewis

Posted by admin  · 16-04-2015 - 14:22

Hello, Using the conversion plugin based on LibreOffice, a PDF is create in the same folder than the DOCX. Then this PDF is moved to the guessed destination with the rename function of PHP. Please check that the destination folder exists and it has the right rw access, and run the script using the CLI mode. If you need to debug it please open the TransformDocAdvLibreOffice.inc class and echo the variables $newDocumentPath and $docDestination (around line 86 of this file). If you need further support please write directly to contact[at]phpdocx.com Regards.

Posted by lewisrblack  · 16-04-2015 - 14:53

I have run the following command from the command line; /Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --convert-to pdf /Library/WebServer/Documents/docxtest/docs/test.docx The output of this is; convert /Library/WebServer/Documents/docxtest/docs/test.docx -> /Library/WebServer/Documents/docxtest/test.pdf using filter : writer_pdf_Export As you can see it's not creating the pdf in the same directory. It is saving the converted file to the parent directory. Looks like an issue with LibreOffice potentially? Is there anything to configure in LibreOffice I need to be aware of? Thanks, Lewis

Posted by admin  · 16-04-2015 - 16:21

Hello, Maybe LibreOffice for MacOS works in a differente way that Linux and Windows versions. The easiest solution could be to add in your script a line to move the PDF from the root folder to the desired target path. Also please try setting absolute paths to both files when you invoke the transformDocument method. Regards.