Snappy PDF Bundle – bad response with download

In my Symfony project I am using wkhtmltopdf where I have my twig view generated and ready do download as pdf. I think my configuration is correct, but I still get an error and I can’t find any answer online.

I want download is triggered when I hit the route.

Error response is:

“The exit status code ‘127’ says something went wrong:nstderr: “sh: 1: /usr/local/bin/wkhtmltopdf: not foundn”nstdout: “”ncommand: /usr/local/bin/wkhtmltopdf –lowquality –page-size ‘A4’ ‘/tmp/knp_snappy5df8f028095875.58492064.html’ ‘/tmp/knp_snappy5df8f028096326.15236548.pdf’.”

My code:

 public function getStatementForPdf()
    $html = $this->renderView('@CustomTemplates/statements/statement.html.twig', array());

    $filename = sprintf('test-%s.pdf', date('Y-m-d'));

    return new Response(
            'Content-Type'        => 'application/pdf',
            'Content-Disposition' => sprintf('attachment; filename="%s"', $filename),

and in my config.yml

    enabled:    true
    binary:     /usr/local/bin/wkhtmltopdf
        - { name: 'page-size', value: 'A4' }
    enabled:    true
    binary:     /usr/local/bin/wkhtmltoimage
        - { name: 'page-size', value: 'A4' }

What am I missing?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *