0
 $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoicesSet);
                $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
'.pdf', $pdf->render(), 'application/pdf');   

I am trying to download all invoice in PDF and need to Save in Magento root folder.

But it's downloading in browser only.

Can any one help for this issue.

  • 2
    Please don't save it into the root folder as pdfs in the root folder would be downloadable. – Kristof at Fooman Feb 17 '16 at 7:34
  • Thanks for valuable reply, Can you please provide any way for "How can i download the PDF file in to magento root folder ?" – Ramesh Feb 17 '16 at 7:41
4

This

 $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s'). '.pdf', $pdf->render(), 'application/pdf'); 

would send it to the browser. The below would write to a file in the var directory instead:

$name = 'invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s'). '.pdf';
file_put_contents(Mage::getBaseDir('var').DS.$name,$pdf->render());
| improve this answer | |
1

You can try with this method

$pdf->save(Mage::getBaseDir('var'). DS . 'tmpfolder' . DS 'filename.pdf');

This will save a local copy, just be aware folder permissions.

Greetings

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.