Question

Default logo dimensions for invoice is 200*50.If I upload image with dimensions 216*100.How to set size in the code.So far,I've tried changing

protected function insertLogo(&$page, $store = null)
    {
        $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);
                $page->drawImage($image, 25, 820, 125, 900);
            }
        }
        //return $page;
    }

This doesn't seem to work.

Was it helpful?

Solution

You'll want the content box arguments to be [25, 775, 133, 825].

Used units seem to be double the pixels and the vertical dimension starts at the bottom of the page. Enough to spend hours trying to make small changes to PDF print-outs.

Also, you'll have to push the rest of the page down a bit as the new image is a bit taller.

The whole insertLogo() function would look something like this:

protected function insertLogo(&$page, $store = null)
{
    $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);
            $page->drawImage($image, 25, 775, 133, 825);
            $this->y = 760;
        }
    }
    //return $page;
}

That said, you may want to consider back porting the function from Magento 1.7, where this all is automatically calculated from dimensions of the actual image.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top