barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.64k stars 291 forks source link

The exit status code '126' says something went wrong #51

Closed anouarabdsslm closed 4 years ago

anouarabdsslm commented 9 years ago

Hi barry, when I hit my end point I get this exception:

The exit status code '126' says something went wrong: stderr: "sh: /Users/xroot/dev_projects/meetings/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: cannot execute binary file " stdout: "" command: /Users/xroot/dev_projects/meetings/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality '/var/folders/ml/gzjp_czs0l9gcvwl4t297gn80000gp/T/knp_snappy555e07f59eaa96.81797228.html' '/var/folders/ml/gzjp_czs0l9gcvwl4t297gn80000gp/T/knp_snappy555e07f59ebe31.72659281.pdf'.

My config file:

<?php

return array(

    'pdf' => array(
        'enabled' => true,
        'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),
        'timeout' => false,
        'options' => array(),
    ),
    'image' => array(
        'enabled' => true,
        'binary' => base_path('/vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64'),
        'timeout' => false,
        'options' => array(),
    ),

);

My route end point:

Route::get('pdf',function(){

    $pdf = PDF::loadView('meetings.print');
    return $pdf->download('invoice.pdf');

});
RodrigoBalest commented 9 years ago

I would try checking two things:

Hope it helps!

DavidPhilip commented 9 years ago

I'm getting the exact same error. I switched between both versions and permissions are set to 777. More help would be appreciated!

seanthepottingshed commented 9 years ago

http://stackoverflow.com/questions/5035601/error-running-wkhtmltopdf-error-while-loading-shared-libraries

gdevlugt commented 9 years ago

Also keep in mind that these are Debian Wheezy (7.8) binaries. If you are using Mac OS X or Windows, these binaries won't work.

phaberest commented 8 years ago

@gdevlugt thanks for the hint

pmpr commented 7 years ago

So what to do on a Mac OS X?

mpixelz commented 7 years ago

how to get it to work on mac os x?

phaberest commented 7 years ago

@mpixelz @peyman-mohamadpour use the same as linux

mpixelz commented 7 years ago

got it working.. but how do i set if else on snappy config file? for instance.. im working on mac osx but have deployed the system on linux system.. php_os return Darwin for mac and Linux for server.. the binary paths are different for each of them.. how can i make it switch automatically based on the os?

phaberest commented 7 years ago

I'd use an env variable, set a new one in your .env file

mpixelz commented 7 years ago

that works on the local but base_path(''); does not work on env file on server :(

edit: working using full hard coded path in env thanks for the help :)

bashet commented 6 years ago

@mpixelz Could you please show us what you have done in snappy config file and env file. Thanks

ComputerGuruInTraining commented 6 years ago

I couldn't change the permissions on the server to executable, so it was working on localhost but not on the web server. I changed to barryvdh/laravel-dompdf and this works great as doesn't use a binary file, the package is complete in itself.

csb7 commented 4 years ago

if you use macOS ,

first of all go to http://wkhtmltopdf.org/downloads.html , then download the proper package according to your os . after installing the package do the followings :

in the config/snappy.php file , write the name of the {bin file} which has been installed in /usr/local/bin , which in my case is wkhtmltopdf :

'binary' => '/usr/local/bin/{bin file}'

so :

'binary' => '/usr/local/bin/wkhtmltopdf'

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy. If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

dustbuster commented 4 years ago

Totally ran into this, i did the above suggestions for installing on MacOS, by using brew cask install wkhtmltopdf and my error changed to the below message.

So it seemed to at least make it farther, and then failed ¯_(ツ)_/¯

The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% Warning: Blocked access to file Warning: Blocked access to file [=========> ] 15% Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) Printing pages (6/6) [> ] Preparing [============================================================] Page 1 of 1 Done Exit with code 1 due to network error: ProtocolUnknownError " stdout: "" command: /usr/local/bin/wkhtmltopdf --lowquality '/var/tmp/knp_snappy5f2c54a8bd43b5.68847902.html' '/var/tmp/knp_snappy5f2c54a8bd59d5.18404886.pdf'.