Reputation: 774
I have this error on knpSnappyBundle, i am trying to generate a pdf and then send it by email.
My config look like this :
knp_snappy:
pdf:
enabled: true
binary: \vendor\h4cc\bin\wkhtmltopdf-amd64\bin\wkhtmltopdf-amd64
options: []
Then my controller :
$html = $this->render('AppUserBundle:Emails:envoi-export.html.twig', [
'pointagesList' => $pointagesList,
'user' => $user,
'date' => new \DateTime()
]);
$filename = sprintf('test-%s.pdf', date('Y-m-d'));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
[
'Content-Type' => 'application/pdf',
'Content-Disposition' => sprintf('attachment; filename="%s"', $filename),
]
);
Full error message :
The exit status code '127' says something went wrong: stderr: "sh: 1: /usr/local/bin/wkhtmltopdf: not found " stdout: "" command: /usr/local/bin/wkhtmltopdf --lowquality '/tmp/knp_snappy57970542debe22.97700913.html' '/tmp/knp_snappy57970542dec563.25042325.pdf'.
Upvotes: 2
Views: 19663
Reputation: 285
I replaced the command given in official readme
cp vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 /usr/local/bin/
with following one
cp vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
Upvotes: 0
Reputation: 131
I Solved Problem, Its happening because system doesn't have installed wkhtmltopdf
Plugin.
please Follow Links to install this plugin:-
For mac OS
https://formulae.brew.sh/cask/wkhtmltopdf
sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
For Linux OS
https://computingforgeeks.com/install-wkhtmltopdf-on-ubuntu-debian-linux/
sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
Hope this helps for future endeavors.
Upvotes: 4
Reputation: 378
While trying to figure out same problem, I noticed at another post on this topic that the root directory needs to be specified in the binary location. Adding %kernel.root_dir%
solved this error for me. Try this:
binary: %kernel.root_dir%/../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64
Upvotes: 0
Reputation: 774
I find a working solution.
I hope it can help someone
Upvotes: 0
Reputation: 57
The "binary" chain is the static path of your computer, where you installed wkhtmltopdf. If you installed it via command lines, it should be :
/usr/local/bin/wkhtmltopdf
If you installed it in your vendor repository, it should be there :
/path/to/Symfony/vendor/...
Upvotes: 0