2

I need to include the 'customer's logo' in the PDF file when we download it from invoice.

I tried with the following code.

$page->drawImage($customerLogo, 25, 800, 125, 825);

But it through the following fatal error...

Fatal error: Call to a member function getResource() on a non-object in D:\Application\xampp\htdocs\projects\guardian\lib\Zend\Pdf\Page.php on line 344

Any one knows, how to fix this problem.

Sankar Subburaj
  • 4,992
  • 12
  • 48
  • 79
  • Interesting - that's Zend Framework's file and I believe it is okay. Are you sure you correctly downloaded all files? – Andron Jun 28 '11 at 10:35

2 Answers2

4

I have used this method before:

Place an image in image in your /media folder then where you want the image to appear inser this code:

$image = Mage::getConfig()->getOptions()->getMediaDir().DS.'you-logo-here.png';             
                        if (is_file($image)) {
                            $image = Zend_Pdf_Image::imageWithPath($image);
                            $page->drawImage($image, $x+5, $y-18, $x+45, $y-6);
                        }  

You will have to play with your php drawImage dimensions and coordinates. But this should do it.

Chris Mousdale
  • 505
  • 1
  • 9
  • 21
0

For that error to occur $customerLogo must have been null. The answer is to make sure that $customerLogo is not null.

clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
  • I checked the '$customerLogo' it is not null, its return 'D:\..\..\media\catalog\customer\logo\1307011576pdff.png'. I had that image in that location. – Sankar Subburaj Jun 28 '11 at 11:07
  • 1
    If you check the [Zend drawImage](http://framework.zend.com/manual/en/zend.pdf.drawing.html#zend.pdf.drawing.image-drawing) it shows you need to pass an object, not a string. In fact it should have raised an earlier error about passing the wrong parameter type. – clockworkgeek Jun 28 '11 at 11:26