PHPPdf icon indicating copy to clipboard operation
PHPPdf copied to clipboard

Style PDF

Open smasala opened this issue 13 years ago • 1 comments

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

smasala avatar Sep 18 '12 08:09 smasala

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
}

psliwa avatar Sep 18 '12 08:09 psliwa