I have a problem with the path of my wkhtmltopdf which does not find it a priori. Do you have the beginning of a solution ?

knp_snappy.yaml

knp_snappy:
pdf:
    enabled:    true
    binary:     '%env(WKHTMLTOPDF_PATH)%'
    options:    []
image:
    enabled:    true
    binary:     '%env(WKHTMLTOIMAGE_PATH)%'
    options:    []

.env

    ###> knplabs/knp-snappy-bundle ###
WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf
WKHTMLTOIMAGE_PATH=/usr/local/bin/wkhtmltoimage
###< knplabs/knp-snappy-bundle ###

Controller

/**
 * @Route("/pdf-snappy", name="generate_pdf")
 */
public function snappy(PDF $pdf,UserActivityRepository $userActivityRepository, TestimonyViewRepository $testimonyViewRepository)
{

    $html = $this->renderView('Modules/PDF/test.html.twig');
    
    $pdf->setOption('page-size','A4');
    $pdf->setOption('orientation', 'Landscape');

    return new Response(
        $pdf->getOutputFromHtml($html),
        200,
        array(
            'Content-Type'          => 'application/pdf',
            'Content-Disposition'   => 'inline; filename="' . 'test' . '.pdf"'
        )
    );


}

Thanks for your help in advance.

0

There are 0 best solutions below