In magento1.7, just write following lines in app\code\core\Mage\Wishlist\Helper\Data.php (Data.php) file
public function getpdf()
{
$pdf = new Zend_Pdf();
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
for($i=0; $i<5; $i++) {
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->setFont($font, 24) ->drawText('Hello World page '.$i, 72, 720);
$pdf->pages[] = $page;
}
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=myfile.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
}
Call this function
<?php Mage::helper('wishlist')->getpdf();?>
in app\design\frontend\base\default\template\wishlist\view.phtml (view.phtml)file just before <div class="my-wishlist">
line. Now run magento in browser and login. Then click on My wishlist link and it will show myfile.pdf in downlods folder. When it is opened it throws error message.Now replace these lines
$pdfString = $pdf->render();
header("Content-Disposition: attachment; filename=myfile.pdf");
header("Content-type: application/x-pdf");
echo $pdfString;
with
$pdf->save("mydoc.pdf");
Then open mydoc.pdf in magento1.7 folder, it's opened with no error and displays "Hello World" on each pages of Pdf document. Now compare these two files "myfile.pdf" and "mydoc.pdf" in text editor, you will see presence of html contents in "myfile.pdf". My problem is that I am not able to find a way for removing these html contents from generated PDF document. Can anybody help me in resolving this issue. Please note that above code is just a demostration of what I did.