0
votes

I am using knp snappy bundle in symfony 2 ,when I tried this code below i get the error "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_snappy5730ffc6454157.04526188.html' '/tmp/knp_snappy5730ffc6454549.48294109.pdf'."

public function showtestAction()
{
    $html = $this->renderView('CondorsTnMallBundle:SimpleVisitor:test.html.twig');

    return new Response(
        $this->get('knp_snappy.pdf')->getOutputFromHtml($html),
        200,
        array(
            'Content-Type'          => 'application/pdf',
            'Content-Disposition'   => 'attachment; filename="file.pdf"'
        )
    );
}
2
Install wkhtmltopdf.malcolm
Yeah i installed, but still not workingSouheib Selmi
So where it's installed? type which wkhtmltopdf in console and change path in knp snappy configuration.malcolm

2 Answers

1
votes

The error message is quite clear: /usr/local/bin/wkhtmltopdf does not exist

First of all you need to know where wkhtmltopdf is in your filesystem. Then, you can add to your config.yml file these lines:

knp_snappy:
    pdf:
        enabled:    true
        binary:     /real/path/to/your/file/wkhtmltopdf
        options:    
          print-media-type: true
0
votes

This works for me, just rename wkhtmltopdf-amd64 to wkhtmltopdf. Test older versions too.

knp_snappy:
pdf:
    enabled:    true
    binary:     /real/path/to/your/file/wkhtmltopdf
    options:    
      print-media-type: true