barryvdh / laravel-snappy

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

Can't load header and footer #479

Closed lucas-gestonauta closed 1 year ago

lucas-gestonauta commented 2 years ago

I've tried a lot of different ways to make a basic footer, but with no success, just don't load anything. After forcing an error, I could see this message:

"The switch --footer-center, is not support using unpatched qt, and will be ignored."

When I check the version of wkhtmltopdf via terminal, it returns: wkhtmltopdf 0.12.6 (with patched qt).

The binary path of snappy.php is like this: 'binary' => 'wkhtmltopdf', That was the only way that works for me.

The real folder of the file is /usr/local/bin/wkhtmltopdf, but if I change the value from "wkhtmltopdf" to "/usr/local/bin/wkhtmltopdf" it returns error code 127 (not found).

If I run "/usr/local/bin/wkhtmltopdf --footer-center 'Page [page] of [topage]' www.google.com /home/lucassouzap/test.pdf" it works perfectly rendering the footer! Even only "wkhtmltopdf --footer..." also works via terminal.

Just don't know what binary file the app is using and don't know what to do to make the footer render...

I'm using Laravel Sail, Ubuntu 20.04 on docker.

JerryBels commented 2 years ago

[EDIT] FYI I got it to work by customizing my dockerfile further to install patched QT version. You publish the dockerfile then instead of just adding && apt-get install -y wkhtmltopdf you do :

&& apt-get install -y xfonts-75dpi wget \
&& wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb \
&& apt install -y ./wkhtmltox_0.12.6-1.focal_amd64.deb \
&& rm ./wkhtmltox_0.12.6-1.focal_amd64.deb \

Then headers and footers will work as intended.

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.