KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Home Page:https://knplabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snappy doesn't work on MAC OS M1 Pro

aosevan opened this issue · comments

I'm using Laravel within the Laradock environment. When I use Snappy to generate a PDF, I encounter the following error message

The exit status code '133' says something went wrong:
stderr: "rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
Trace/breakpoint trap
"
stdout: ""
command: /var/www/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality --margin-left '0mm' --margin-right '0mm' --margin-top '0mm' '/tmp/knp_snappy653b7ea1053c69.97552473.html' '/tmp/knp_snappy653b7ea10550a9.74385629.pdf'. {"exception":"[object] (RuntimeException(code: 133): The exit status code '133' says something went wrong:
stderr: "rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
Trace/breakpoint trap
"
stdout: ""
command: /var/www/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality --margin-left '0mm' --margin-right '0mm' --margin-top '0mm' '/tmp/knp_snappy653b7ea1053c69.97552473.html' '/tmp/knp_snappy653b7ea10550a9.74385629.pdf'. at /var/www/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php:469)
[stacktrace]
#0 /var/www/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(194): Knp\Snappy\AbstractGenerator->checkProcessStatus(133, '', 'rosetta error: ...', '/var/www/vendor...')

But this package is working in Linux OS

Hello,
I'm not familiar with Laradock environment but I would say that the issue is with the wkhtmltopdf binary you installed on your MacOS M1 Pro.
I guess that, if you run the wkhtmltopdf command from a command line, you'll get the same result right?

It works for me on Mac M1.

I just installed this. Maybe you need to adjust the path to wkhtmltopdf in your installation.
https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-2/wkhtmltox-0.12.6-2.macos-cocoa.pkg
From here https://wkhtmltopdf.org/downloads.html

thanks, problem related to wkhtmltopdf