Symfony 2 - Generate PDF with Knp-Snappy output HTML -
i have problem knp-snappy bundle in symfony2 project. followed link install : http://knpbundles.com/knplabs/knpsnappybundle. whenever click on link generate pdf twig view, renders me html page , doesn't generate pdf.
here's print part of controller.
$html = $this->renderview('pacescollebundle:classement:generationpdf.html.twig', array( "passercolles" => $passercolles, "colle" => $colle, "moyenne" => $moyenne, "mediane" => $mediane, "effectif" => $effectif, "note100" => $note100 )); return new response( $this->get('knp_snappy.pdf')->getoutputfromhtml($html), 200, array( 'content-type' => 'application/pdf', 'content-disposition' => 'attachment; filename="classement.pdf"' ) );
my guess in view produces notice / warning, headers sent , @ point late send pdf response.
remove view generation , pass static html test pdf generation itself, i.e.:
$html = "just sample text produce pdf"; return new response( $this->get('knp_snappy.pdf')->getoutputfromhtml($html), 200, array( 'content-type' => 'application/pdf', 'content-disposition' => 'attachment; filename="classement.pdf"' ) );
also please check application logs in /app/logs/*.log.
Comments
Post a Comment