0

how can I add store link in invoice pdf under logo in magento 1.9

1 Answer 1

0

One way to do that:

You should rewrite Mage_Sales_Model_Order_Pdf_Invoice class, and provide your own insertLogo() method

More info http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/

This is the original, in Mage_Sales_Model_Order_Pdf_Abstract abstract class

protected function insertLogo(&$page, $store = null)
{
    $this->y = $this->y ? $this->y : 815;
    $image = Mage::getStoreConfig('sales/identity/logo', $store);
    if ($image) {
        $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
        if (is_file($image)) {
            $image       = Zend_Pdf_Image::imageWithPath($image);
            $top         = 830; //top border of the page
            $widthLimit  = 270; //half of the page width
            $heightLimit = 270; //assuming the image is not a "skyscraper"
            $width       = $image->getPixelWidth();
            $height      = $image->getPixelHeight();

            //preserving aspect ratio (proportions)
            $ratio = $width / $height;
            if ($ratio > 1 && $width > $widthLimit) {
                $width  = $widthLimit;
                $height = $width / $ratio;
            } elseif ($ratio < 1 && $height > $heightLimit) {
                $height = $heightLimit;
                $width  = $height * $ratio;
            } elseif ($ratio == 1 && $height > $heightLimit) {
                $height = $heightLimit;
                $width  = $widthLimit;
            }

            $y1 = $top - $height;
            $y2 = $top;
            $x1 = 25;
            $x2 = $x1 + $width;

            //coordinates after transformation are rounded by Zend
            $page->drawImage($image, $x1, $y1, $x2, $y2);

            $this->y = $y1 - 10;
        }
    }
}

You can use $page->drawText($text, $x, $y); method for your customization. This method requires $text as first parameter, and then $x & $y coordinates, as second & third parameters. You'll get how coordinates work after a little play

2
  • Thanks, but i want to add link with home page url. like: < a href='site url' > Click < / a >
    – Waqar
    Jan 17, 2018 at 10:31
  • Yeah, you want to add a text under the logo, doesn't it? Jan 18, 2018 at 7:20

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .