Question: PDF and CSV generation are not working

PDF and CSV generation are not working

Installed version Stock Manager Advance with POS Module v3.4.31. The live version is v3.4.29 hence can't test. using PHP 7.3.16 (cli) (built: Mar 17 2020 10:18:38) ( NTS ) with all the rec

BE

Benjamin Eshun

Asked
Installed version Stock Manager Advance with POS Module v3.4.31. The live version is v3.4.29 hence can't test.
using
PHP 7.3.16 (cli) (built: Mar 17 2020 10:18:38) ( NTS ) with all the recommended extensions installed.

The code breaks each time I tried to generate a pdf or CSV file
  • MS

    Mian Saleem

    Answered
    Hello,

    The demo has been updated. You can test. If demo is fine, you can check your server error logs and let me know the error details so that I can suggest.

    Thank you
  • BE

    Benjamin Eshun

    Answered
    Hi,

    The demo seems fine. However nothing comes up in the error logs. Could it be a permissions issue? What are all the folders that need a write permission for the pdf and csv exports for work.

    Grateful for the assistance.
  • NP

    NGUYEn hONG PHONG

    Answered
    error
  • MS

    Mian Saleem

    Answered
    Blank page is mostly caused by 500 internal server error. The error should be logged, you can check the error log again.

    You can enable app logs by changing the `log_threshold` to 1 in `app/config/config.php` and then visit page again to reproduce error. Lastly check the latest log in `app/logs/` folder.

    Thank you
  • BE

    Benjamin Eshun

    Answered
    thanks I'm getting
    Temporary files directory "/var/www/zzzz/data/www/xxxxxxx/vendor/mpdf/mpdf/src/Config/../../tmp" is not writable

    from ....vendor/mpdf/mpdf/src/Cache.php 17

    From the code line 17 is

    throw new \Mpdf\MpdfException(sprintf('Temporary files directory "%s" is not writable', $basePath));

    How do I set the real path is $basePath
  • MS

    Mian Saleem

    Answered
    Hello,

    You are not suggested to change the code. Instead you should change the ownership of the files and folder to www-data or check with your server admin/host for help.

    Thank you
  • BE

    Benjamin Eshun

    Answered
    Hi ,

    Not the code, the path is vendor/mpdf/mpdf/src/Config/../../tmp and the "/../../" should not be in the $basePath variable. How do I remove it from the variable

    Thanks
  • MS

    Mian Saleem

    Answered
    Hello,

    If you want to set custom path then you can edit `app/libraries/Tec_mpdf.php` and replace

    ```php
    $mpdf = new Mpdf();
    ```
    with

    ```php
    $mpdf = new Mpdf(['tempDir' => __DIR__ . '/custom/temp/dir/path']);
    ```
  • BE

    Benjamin Eshun

    Answered
    Hello,

    Your suggestion is noted and will implement.

    On a related issue, we I use the dompdf PDF Library I get the following error...

    ERROR - 2020-04-05 10:45:55 --> Severity: error --> Exception: Class 'DOMDocument' not found /var/www/user/data/www/domain.tld/vendor/dompdf/dompdf/lib/html5lib/TreeBuilder.php 155

    I also get the following errors when I try to generate a CSV file

    ERROR - 2020-04-05 11:11:33 --> Severity: error --> Exception: Class 'XMLWriter' not found /var/www/user/data/www/domain.tld/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php 5

    in both cases "user'" and "domain.tld" are just placeholders of the actual.

    Thanks
  • MS

    Mian Saleem

    Answered
    Hello,

    Please enable/install `php-xml` extension then test both. If still having the dompdf error then you might need tenable/install `php-dom` too.

    Thank you
  • Login to Reply