×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: PHP
Posted by: Massimo Zappino
Added: Sep 2, 2011 2:01 PM
Views: 4586
Via http://zend-framework-community.634137.n4.nabble.com/howto-capture-action-output-stream-it-as-pdf-td671222.html
  1. function toPdfAction()
  2.     {
  3.         // I need a different layout   
  4.         $this->getHelper('layout')->setLayout('pdf-layout');
  5.         $this->_helper->layout->disableLayout();
  6.  
  7.         // we need to do renderering ourselves.  
  8.         $this->getHelper('viewRenderer')->setNoRender();
  9.  
  10.         /* @var $layout Zend_Layout */
  11.         $layout = $this->_helper->layout->getLayoutInstance();
  12.         $layout->assign('content', $this->view->render('mycontroller/myaction.tpl'));
  13.  
  14.         $output = $layout->render();
  15.  
  16.         // now we still need to ensure that the rendering is not sent to the browser
  17.         $this->getResponse()->clearBody();
  18.  
  19.         // now do something with $ouput
  20.     }