wkhtmltopdf temporary file creation failed

(9 posts) (2 voices)


  1. Adrian, Member

    We get this error during the PDF export. Is there any workaround without to modify the server configuration?

    Warning: realpath(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/var/www/vhosts/domain.at:/usr/share/php:/usr/share/php5:/var/www/vhosts/domain.de) in /var/www/vhosts/domain.at/htdocs/mydbr/lib/export.php on line 184

    wkhtmltopdf temporary file creation failed

    Was unable to create the export file to system temporary directory

  2. myDBR Team, Key Master

    your server is configured so that PHP has no access to temp directory. You can change directory to be used with wkhtmltopdf by adding definition to the 'Server side files' -> defaults.php:

    $mydbr_defaults['wkhtmltopdf']['tmp_directory'] = 'path/to/new/temp/directory';

    myDBR Team

  3. Adrian, Member

    I have changed the tmp_directory in the files /mydbr/defaults.php and /mydbr/user/defaults.php and got another error without further details.
    (yes that directory exists and it's written correctly) ;-)

    defaults.php $mydbr_defaults['wkhtmltopdf']['tmp_directory'] = '/var/www/vhosts/domain.at/tmp';

    error (german localization) Leider konnten wir Ihre Anfrage nicht abschlie├čen. Wenden Sie sich an Ihren Systemadministrator.

  4. myDBR Team, Key Master

    what were you doing when got the error? PDF export or something else?

    Did you run myDBR at the time as admin (the errror message in question is a generic error shown to normal users and admins may get more detailed error).

    Btw, you should not modify content of /mydbr/defaults.php. You can override all the values in /mydbr/user/defaults.php, but any modifications you make should be restricted to files in /mydbr/user/.

    myDBR Team

  5. Adrian, Member

    Yes, the error occurs only if I want to generate the PDF. Now I've tried with the admin and got a detailed error message.

    works fine - report is shown correctly https://www.domain.at/mydbr/report.php?r=3&u1=04.06.2020&u2=04.06.2020&m=4&h=51023f08fbef6e94357615f1b8063746bcb9f04d

    error occurs https://www.domain.at/mydbr/report.php?r=3&u1=04.06.2020&u2=04.06.2020&m=4&h=51023f08fbef6e94357615f1b8063746bcb9f04d&export=pdf

    There was an error (code:134) producing the pdf document Failed command: wkhtmltopdf -q -O Landscape --margin-top "20" --header-spacing "8" --header-html "https://www.domain.at/mydbr/user/export_header_pdf.php" --replace rdate "04.06.2020" --replace rtime "11:15:17" /var/www/vhosts/domain.at/tmp/mydbr_export_1331255137.html -

  6. myDBR Team, Key Master

    so the wkhtmltopdf execution fails. What is the wkhtmltopdf version you have installed on the server?

    What you can do next is to see the errors in the wkhtmltopdf-creation, by adding following option to the report and rerun the report.

    select 'dbr.export.options', 'debug', 1; 

    With the option, myDBR will create the HTML file and shows you the command it would have executed with wkhtmltopdf. You can then run the same command from the servers command line to see the errors causing error 134. Could be that the wkhtmltopdf version is so old that it requires X-libraries.

    myDBR Team

  7. Adrian, Member

    I have added the debug export option and reruned the report. The html file is created with its correct content in the specified tmp-directory. After that I've run the shown command.

    wkhtmltopdf --version wkhtmltopdf 0.12.1

    wkhtmltopdf debug To test wkhtmltopdf pdf generation, copy the following command into the server's command line. myDBR saved the generated HTML file into /var/www/vhosts/domain.at/tmp/mydbr_export_1722029187.html. File size is: 28393 bytes. $ wkhtmltopdf -O Landscape --margin-top "20" --header-spacing "8" --header-html "https://www.domain.at/mydbr/user/export_header_pdf.php" --replace rdate "04.06.2020" --replace rtime "12:00:02" /var/www/vhosts/domain.at/tmp/mydbr_export_1722029187.html debug_output.pdf

    output: The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --replace, is not support using unpatched qt, and will be ignored.The switch --replace, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display Aborted

  8. myDBR Team, Key Master

    the 0.12.1 is an old release which requires X-libraries to be installed and threfore one needs to call it using xvfb. Easiest solution is to download the latest wkhtmltopdf (0.12.5) and use that. As a bonus, 0.12.5 has many bugs resolved that exists in 0.12.1.

    myDBR Team

  9. Adrian, Member

    Updating to Version 0.12.5 solved the problem. Thank you for your support! *thumbs up*


You must log in to post.