Forum


Replies: 7   Views: 6129
Transform doc to pdf
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 lclemenson  · 12-05-2015 - 08:10

Phpdocx works fine to create documents but I get that error when I want to transform a doc in a pdf : Notice: Undefined index: method in vendor/phpdocx/Classes/Phpdocx/Create/CreateDocx.inc line 5141 Here is my code : $docx = new \Phpdocx\Create\CreateDocx(); $docx->enableCompatibilityMode(); $docx->transformDocument('/var/www/oscar/web/CV/example_text.docx', '/var/www/oscar/web/CV/example_text.pdf', 'script'); Thanks for your help

Posted by admin  · 12-05-2015 - 08:29

Hello, Please check your phpdocxconfig.ini, it seems the default INI structure [transform] is missing. Enable the method and path options removing the ';' of feach line. and set its values. Also note that the third parameter of transformDocument is the temp folder, not the option parameters that is an array. http://www.phpdocx.com/api-documentation/format-conversion/convert-Word-docx-into-pdf-with-PHP Regards.

Posted by lclemenson  · 12-05-2015 - 09:45

Hello, Ok I've fixed that issue and install libreoffice : my confi file looks like that : [transform] ; transform options. Only available for Corporate and Enterprise licenses. OpenOffice by default ; libreoffice or openoffice method = "libreoffice" ; libreoffice installation path, absolute path path = "/opt/libreoffice4.4/program/soffice" But now I'm getting that mistake : Warning: syntax error, unexpected '(' in /var/www/oscar/vendor/phpdocx/Classes/Phpdocx/Utilities/../../../config/phpdocxconfig.ini on line 2 in /var/www/oscar/vendor/phpdocx/Classes/Phpdocx/Utilities/PhpdocxUtilities.inc line 59 Thanks for your help

Posted by admin  · 12-05-2015 - 10:29

Hello, You're getting a INI parse error.: Warning: syntax error, unexpected '(' in /var/www/oscar/vendor/phpdocx/Classes/Phpdocx/Utilities/../../../config/phpdocxconfig.ini on line 2 Please check your config/phpdocxconfig.ini. It seems you added a '(' outside any of the options. Or send to contact[at]phpdocx.com the file. Regards.

Posted by lclemenson  · 12-05-2015 - 11:36

Hello, Thanks for your help, I've just commented the second line ; libxml_disable_entity_loader(true); and it works again to create the doc document. But still stuck with the following error : Warning: rename(/var/www/oscar/docs/example_text.pdf,/var/www/oscar/docs/example_text.pdf): No such file or directory in /var/www/oscar/vendor/phpdocx/Classes/Phpdocx/Transform/TransformDocAdvLibreOffice.inc line 96 The code I'm using is the following : $docx = new \Phpdocx\Create\CreateDocx(); $docx->enableCompatibilityMode(); $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' . 'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' . 'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' . 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' . 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' . 'officia deserunt mollit anim id est laborum.'; $docx->addText($text); $docx->createDocx('/var/www/oscar/docs/example_text'); $docx->transformDocument('/var/www/oscar/docs/example_text.docx', '/var/www/oscar/docs/example_text.pdf'); It create the docx but does not transfom it. Thanks

Posted by admin  · 12-05-2015 - 12:09

Hello, Please follow this steps and post where you get to an error: http://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice Regards.

Posted by lclemenson  · 12-05-2015 - 13:08

Thanks for the answer. Step one : Libreoffice works fine and create the document. but I can't do the following test because I use the namespace version ! I can install another version to test but if you have any other idea I would prefer it !

Posted by admin  · 12-05-2015 - 14:20

Hello, The step after checking is there's another LibreOffice installation is to run the included example. It doesn't matter if you're using the NS version, you just need to run this example with the PHP CLI mode in a terminal to check if the problem is with the web server or PHP. After checking it, the problem was in the /var/www/.config folder. This folder was missing and needed rw access to the apache user. 4th point: http://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice Regards.