symfonypdf-generationwkhtmltopdf

KnpSnappyBundle The exit status code '127' says something went wrong:


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'.


Solution

  • I find a working solution.

    I hope it can help someone