コード例 #1
0
ファイル: GuiaController.php プロジェクト: astrakel/web
 public function getPdfAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $guia = $em->getRepository('EtsiAppGuiasBundle:Guia')->find($id);
     if ($guia) {
         $facade = $this->get('ps_pdf.facade');
         $response = new Response();
         $this->render('EtsiAppGuiasBundle:PDF:guia.pdf.twig', array('guia' => $guia), $response);
         $documentXml = $response->getContent();
         $this->render('EtsiAppGuiasBundle:PDF:guia.style.twig', array(), $response);
         $stylesheetXml = $response->getContent();
         $content = $facade->render($documentXml, $stylesheetXml);
         $asignatura = $guia->getAsignatura();
         $curso = $asignatura->getCurso();
         $nombre = Herramientas::slugify($asignatura->getNombre());
         $header = array('content-type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $asignatura->getId() . '.pdf"');
         return new Response($content, 200, $header);
     }
     return $this->indexAction(array('error' => array('No se ha podido cargar la guía')));
 }