barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.63k stars 290 forks source link

The option '0' doesn't exist. #470

Closed geraldofebrian closed 2 years ago

geraldofebrian commented 2 years ago

I tried to put --disable-forms inside snappy config but doesn't work. Tried another also didn't work.

'pdf' => [
        'enabled' => true,
        'binary'  => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
        'timeout' => 60,
        'options' => ['--disable-forms'],
        'env'     => [],
    ],

How to solve it?

mralston commented 2 years ago

I believe Snappy (or Laravel Snappy) assumes the options array contains key-value pairs. As you've only passed a value, the key is 0. Also, I think it adds the -- for you, so you don't need to. It will be trying to execute something like this:

/usr/local/bin/wkhtmltopdf --0=--disable-forms <input> <output>

Try this instead:

'pdf' => [
        'enabled' => true,
        'binary'  => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
        'timeout' => 60,
        'options' => ['disable-forms' => true],
        'env'     => [],
    ],
stale[bot] commented 2 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.