Forum


Replies: 6   Views: 4368
Error generating pdf file from docx
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 david.costa@swyftfilings.com  · 04-11-2018 - 07:48

Using AWS Elastic Beanstalk. System creates .docx perfect. But it fails during the conversion to pdf.

This is the error thrown:

rename(/var/app/current/storage/app/public/360lf_5bdea34a19f20.pdf,/var/app/current/storage/app/public/360lf_5bdea34a19f20.pdf): No such file or directory

I also followed the list of steps for debugging and pdf is created from CLI, but it doesn't in Apache. I created .config folder in /home/ec2-user and /var/app/current (just testing wich one you refer as home), with no success.

Is there any other way to fix it?

Thanks 

Posted by admin  · 04-11-2018 - 10:07

Hello,

As it's working using PHP CLI mode, we recommend you to get the correct HOME path of Apache user:

<?php
echo getenv("HOME");

or set a custom HOME path, for example to /var/www and create the .config folder:

$ mkdir /var/www/.config

<?php
putenv("HOME=/var/www");

And set 777 access to the .config folder and all its subdirectories

$ chmod 777 -r /var/www/.config

And also check your server logs to find any issue when doing the conversion or some PHP or Apache configuration is blocking the conversion.

On https://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice and https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors you can read about common issues when working with the conversion plugin.

Regards.

Posted by david.costa@swyftfilings.com  · 04-11-2018 - 16:48

I did everything as you suggested, and still got same error:

In the following image you can see .config file was created with the proper permission in the document root folder, in this case, for Laravel + Elastic Beanstalk, that folder is: /var/app/current/public

https://s3.amazonaws.com/swyftfilings-resources/Screen+Shot+2018-11-04+at+10.45.03+AM.png

Posted by admin  · 04-11-2018 - 18:12

Hello,

Sorry, but we don't know what could be wrong in the server setup. As it's working using the PHP CLI mode, some Apache or PHP configuration or some missing rw access may be blocking the conversion.

We recommend you to enable the debug option (https://www.phpdocx.com/api-documentation/format-conversion/convert-Word-docx-into-pdf-with-PHP) and check your server logs to find the source of the problem. Also, check if some external tool such as SELinux or similar is enabled.

Regards.

Posted by david.costa@swyftfilings.com  · 05-11-2018 - 00:53

This are my system variables got after running check.php

OK PHP version is 7.2.5
OK Zip support is enabled.
OK DOM support is enabled.
OK XML support is enabled.
OK Tidy support is enabled.
OK mbstring is enabled.


PHP_VERSION: 7.2.5
PHP_OS: Linux
PHP_UNAME: Linux ip-172-31-43-228 4.14.62-65.117.amzn1.x86_64 #1 SMP Fri Aug 10 20:03:52 UTC 2018 x86_64
SERVER_NAME: 
SERVER_SOFTWARE: 
SERVER_ADDR: 
SERVER_PROTOCOL: 
HTTP_HOST: 
HTTP_X_FORWARDED_FOR: 
PHP_SELF: check.php
ZipArchive: 1
DomDocument: 1
SimpleXMLElement: 1
Tidy: 1
mbstring: 1

Config file: 
[settings]
temp_path = "/var/app/current/storage/app/public"

encode_to_UTF8 = "false"

language = "en-US"

paper_size = "A4"

[license]

code = "XXXXXXXXXXXXX"
value = ""

[transform]

method = "libreoffice"
path = "/opt/libreoffice6.1/program/soffice"

I still need your help to solve it, since I can convert docx to pdf from CLI already, and same in localhost.

 

 

Posted by admin  · 05-11-2018 - 07:16

Hello,

We are trying to help you, and as it's working with PHP CLI, we are sure the problem must come from a PHP or Apache configuration or some program such as SELinux that is blocking PHP to call the conversion plugin. Did you enable the debug option and check your server logs?

Please send to contact[at]phpdocx.com the information to connect to your server through SSH, the path where phpdocx is installed and an URL to test it using a web browser and we'll check it.

Regards.

Posted by admin  · 13-11-2018 - 08:48

Hello,

After checking the server, the problem was the detailed on our first reply. To solve it, we just set a custom HOME folder

putenv("HOME=/var/www");

And set 777 access to the .config folder and all its subdirectories

$ chmod 777 -r /var/www/.config

Regards.