In Magento Backend, when looking at an invoice details, it is possible to get a pdf version in clicking the "print" button.

Is there a way to get this pdf invoice using a php script?

1 Answer 1


You can use:

$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));

where $invoice is the invoice object.

  • Thanks for your help, but it logs me an error : Not valid template file:frontend/base/default/template/payment/info/pdf/default.phtml
    – Alexglvr
    Apr 22, 2015 at 17:53
  • 2
    Ok, so if you look at app/code/core/Mage/Payment/Block/Info.php, you will see a method called "toPdf" which sets the template for the info block. You dont need to change this, but rather copy the template to your theme folder. The template can be found in: "app/design/adminhtml/default/default/template/payment/info/pdf/default.phtml". Copy that to your theme folder and re-test.
    – Shaughn
    Apr 23, 2015 at 8:52
  • no more error but neither pdf….
    – Alexglvr
    Apr 23, 2015 at 17:23
  • Is my code right : paste.ofcode.org/sjZ3JbN7cKKp4raX9j3Ree
    – Gem
    Mar 1, 2018 at 12:54

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.