0

When I'm printing a PDF the logo size gets way too big with a size of 360x200px. Instead, I'd like it to be 180x100px.

How and where can I edit this?

  • upload a logo with size of 180*100 and to admin>System>Configuration>Sales>Invoice and Packing Slip Design>Logo for PDF Print-outs changer here – Amit Bera Sep 29 '14 at 8:30
  • @AmitBera The logo is constantly resized, so when I uploaded the logo in 180x100px it was resized to 240x140px. – McKeene Sep 29 '14 at 8:43
1

The image is inserted by the method Mage_Sales_Model_Order_Pdf_Abstract::insertLogo.
There is some resizing done there but if your image is smaller than 270x270 nothing should be resized.
If you have any custom extension that changes the invoice pdf disable it.

0

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.

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.

I hope this will help you.

0

Magento insert image in pdf file from below file

app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

Mage_Sales_Model_Order_Pdf_Abstract::insertLogo()

        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;
        }

This is the core file you need to override in local and change below variable's value to

$widthLimit = 180; $heightLimit = 100;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.