How to call the following two lines in magento’s \app\code\core\Mage\Wishlist\Helper\Data.php file
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
Actually there is a self created function getPdf() in Data.php which is used to generate pdf of wishlist items. It generates PDF with no error by using the statement
$pdf->save("hello.pdf");
But When I use the following statement
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=myfile.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
It throws error: Adobe reader couldn’t open myfile.pdf because it’s not either a supported file type or because the file has been damaged. Now I need to call these two lines
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
in getPdf() function so that, it will not add html contents in pdf documents. Can you help me in this?
Before you echo
$pdfString, add the following code to disable view rendering and the layout:If the
Mage::getSingleton()call doesn’t return the correct layout object, you can also try$layout = $this->getLayout();