PDF attachment to the order invoice email magento

January 31st, 2010 Categories: Magento

I have spent one month for PDF attachment to the order invoice email magento  different ways and nothing seems to work.  I am trying to attach a packing slip PDF to a packing slip email that is send to the store admin when a new order is placed.  I don’t know if the problem is with me (probably) or with Zend_Pdf or with Zend_Mail or with Magento.

Mage/Sales/Model/Order.php

Mage/Core/Model/Email/Template.php

Mage/Sales/Model/Order/Invoice.php

After days of working on this, I’ve discovered that Zend_Pdf doesn’t work with HTML.  You have to build the PDF from scratch, which is more work than it’s worth and not easy to edit if you want to change the design.

$pdf = Mage::getModel(’sales/order_pdf_invoice’)->getPdf(array($this));
$mailTemplate->addAttachment($pdf, “INVOICE_”.$this->getIncrementId().”.pdf”);

public function addAttachment(Zend_Pdf $pdf, $filename){
$file = $pdf->render();
$attachment = $this->getMail()->createAttachment($file);
$attachment->type = ‘application/pdf’;
$attachment->filename = $filename;
}

follow the url : http://www.magentocommerce.com/extension/1251

Tags: , , , ,

One Response to “PDF attachment to the order invoice email magento”

Leave a Comment