I'm trying to print the PDF using knp_snappy bundle. Every thing seems to be working seamlessly except for the JS. The twig template it self contains a form with a large number of input fields. I need to execute JS to hide the labels for the input fields which are empty before generating the PDF. Prior to printing, empty input fields are not known.Here's what I have tried so far:
$reportHTML = $this->render('template.html.twig', array());
$options = array(
'enable-javascript' => true,
'javascript-delay' => 1000,
'no-outline' => true,
'image-dpi' => 600,
'image-quality' => 100,
'margin-top' => 2,
'margin-right' => 0,
'margin-bottom' => 5,
'margin-left' => 0,
'page-width' => '22cm',
'page-height' => '36cm',
);
$snappyPdf = $this->get('knp_snappy.pdf');
$snappyPdf->setOptions($options);
$snappyPdf->setOption('enable-local-file-access', true);
return new PdfResponse(
$snappyPdf->getOutputFromHtml($reportHTML),
"contract.pdf"
);