Insert custom image into Magento Invoice or Packingslip PDF using Zend Framework
I am trying to insert a new image into my Magento invoice or packing slip, and I have found this code: (from /app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php)
protected function insertLogo(&$page, $store = null)
{
$image = Mage::getStoreConfig('sales/identity/logo', $store);
if ($image) {
$image = Mage::getStoreConfig('system/filesystem/media', $store) . '/sales/store/logo/' . $image;
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, 25, 758, 170, 860);
}
}
//return $page;
}
I have made a copy in my local folder of /app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php which is the file i am trying to modif开发者_JAVA技巧y. I have tried various methods to point to a file i have on my server (not uploaded through the admin, just via FTP) but i can not get it to point to another file - it just refuses to create PDF or does nothing...
this is where I am at so far:
$image = Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif');
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, $x, $y, $x+30, $y+15);
}
Any ideas?
For Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif')
to work there needs to be a setting called system/filesystem/media/Chris-Sig.gif
, that is not a file location. Try this simpler but non-configurable snippet:
$image = Mage::getConfig()->getOptions()->getMediaDir().DS.'Chris-Sig.gif';
When you're confident it works you can experiment with configuration settings.
精彩评论