PHPPdf
PHPPdf copied to clipboard
Style PDF
When rendering a PDF ready to be sent via email... How can I pass it the correct stylesheet? The rendering is done inside a function and not an action - hence I cannot use the annotation here.
protected function sendmailpdf($something){ $facade = $this->get('ps_pdf.facade'); $response = new Response(); $this->render('BUNDLE:Print:something.pdf.twig', array("something" => $something), $response); $xml = $response->getContent(); $content = $facade->render($xml); }
Thanks
Second argument of $facade->render is stylesheet content. For example this code should work:
protected function sendmailpdf($something){
$facade = $this->get('ps_pdf.facade');
$response = new Response();
$this->render('BUNDLE:Print:something.pdf.twig', array("something" => $something), $response);
//parse stylesheet template
$stylesheetXml = $this->renderView('BUNDLE:Print:somethingStylesheet.pdf.twig', array());
$xml = $response->getContent();
//pass stylesheet as second argument
$content = $facade->render($xml, $stylesheetXml);
//do sth
}