spiritix / php-chrome-html2pdf

A PHP library for converting HTML to PDF using Google Chrome
MIT License
112 stars 29 forks source link

Shell error 127 on linux ECS aws server but works fine on local #53

Closed codinglife456 closed 7 months ago

codinglife456 commented 1 year ago

The library works fine on local host however after pushing it to the production branch and running composer require spiritix/php-chrome-html2pdf, I am now receiving shell error 127

                    $stringInput = new StringInput();
                    $stringInput->setHtml($html_of_page);
                    $converter = new Converter($stringInput, new StringOutput());
                    $converter->setOptions([
                        'printBackground' => true, //Print background is required to have background color styling take effect
                        'displayHeaderFooter' => true,
                        'format' => "A4",
                        'headerTemplate' => '<div></div>',
                        'footerTemplate' => '<div style="margin: 0px 40px; display:flex; align-items:flex-end; align-content:flex-end; justify-content:flex-end ; width:100vw!important; font-size:10px !important;"><p class="pageNumber"></p><p>/</p><p class="totalPages"></p></div>',
                        'margin' => ['top' => '40px', 'bottom' => '70px', 'left' => '40px', 'right' => '40px']
                        ]);
                    $converter_output = $converter->convert();

Error message production.ERROR: Shell error: 127 {"exception":"[object] (Spiritix\\Html2Pdf\\ConverterException(code: 0): Shell error: 127 at /var/www/html/vendor/spiritix/php-chrome-html2pdf/src/Spiritix/Html2Pdf/Converter.php:$ [stacktrace]

Attempted solutions 1) I have tried changing permissions and ownership to the Converter.php file however the error remains image

2) I have also tried to specify the filepath of node $converter->setNodePath('/home/ec2user/.nvm/versions/node/v10.16.0/bin'); however this results in shell error 126 but upon inspecting the permission node it is already -rwxrwxr-x 1 ec2-user ec2-user 41115408 May 28 2019 node

MarcPinnell commented 1 year ago

Any solution found for this? Getting the same error on a Linux install.

codinglife456 commented 1 year ago

Yup, managed to resolve it by changing the executable permission allowing access to apache on /home/ec2user which previously wasn't granted @MarcPinnell

sindev95 commented 1 year ago

Yup, managed to resolve it by changing the executable permission allowing access to apache on /home/ec2user which previously wasn't granted @MarcPinnell

i'm having same issue even tho i granted full permission to my node executable but i'm still getting "Shell error: 126"

can you give a bit detailed explanation if possible / you remember how you fixed it i'll be grateful

thanks in advance

spiritix commented 7 months ago

Manually set the path to your Node.js executable using the $converter->setNodePath() method.

sindev95 commented 7 months ago

Manually set the path to your Node.js executable using the $converter->setNodePath() method.

even if you set the path and with correct permission it didn't work for some reason especially on EC2 RHEL , any other EC2 instances works fine

main issue is RHEL doesn't grant permission for node to execute for god knows why even if it has the needed permission while it works fine on other os