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
  • 2
    Please don't save it into the root folder as pdfs in the root folder would be downloadable. Feb 17, 2016 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, 2016 at 7:41

2 Answers 2

5

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());
0
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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