KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
https://knplabs.com
MIT License
4.4k stars 436 forks source link

Installation: wkhtmltoimage-amd64 not found #486

Closed RyanPaiva56 closed 1 year ago

RyanPaiva56 commented 1 year ago

Hi, I tried a ton of things and still not able to get it to work:

I installed via composer:

https://github.com/h4cc/wkhtmltopdf-amd64

Here's my controller code:

$snappy = new Pdf('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
echo $snappy->getOutput('localhost/schedule');

I get this error:

[2023-09-02 21:54:47] local.ERROR: The exit status code '127' says something went wrong: stderr: "sh: 1: vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: not found

Any ideas?

RyanPaiva56 commented 1 year ago

I swear to god I worked on this for like 20 minutes, and as soon as I posted the issue, I thought of needing to use base_path. For anyone else who googles this here ya go:

$snappy = new Pdf(base_path() . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');