Question

I'm trying to output a PDF of a twig file using Snappy oh my Symfony project. When I click the link my page redirects and I get the following exception:

The exit status code '1' says something went wrong:
stderr: "The system cannot find the path specified.
"
stdout: ""
command: /usr/local/bin/wkhtmltopdf --lowquality "C:\Users\user\AppData\Local\Temp\knp_snappy52333e6a9d6731.29137239.html" "C:\Users\user\AppData\Local\Temp\knp_snappy52333e6a9e84c9.03326780.pdf".

I checked the AppData folder and the html file has been rendered. There is no PDF which is what I assume Snappy is trying to generate.

I have a call similar to the following in my controller:

$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
    'some'  => $vars
));

return new Response(
    $this->get('knp_snappy.pdf')->getOutputFromHtml($html),
    200,
    array(
        'Content-Type'          => 'application/pdf',
        'Content-Disposition'   => 'attachment; filename="file.pdf"'
    )
);

This is my config.yml

knp_snappy:
    pdf:
        enabled:    true
        binary:     /usr/local/bin/wkhtmltopdf
        options:    []
    image:
        enabled:    true
        binary:     /usr/local/bin/wkhtmltoimage
        options:    []

Is there something that I have missed? I am running this on my local Windows machine, could it be a permissions error?

Was it helpful?

Solution 2

The issue was that I hadn't installed wkhtmltopdf, doh!

OTHER TIPS

Most likely you have put the wrong path to the executable file.

/usr/local/bin/wkhtmltopdf - Linux path to wkhtmltopdf binary.

You must find where your wkhtmltopdf placed and set right path at config.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top