N.G.Ashok kumar
N.G.Ashok kumar

Reputation: 1

Invoice pdf Logo Image issue

Hi In Magento I want to use a Big logo in my Invoice and packaging details page and whatever image i'm uploading in the backend under configuration->sales->Invoice

It scaling to 200 * 50 and i don't know how to solve this..

anybody help

Upvotes: 0

Views: 6026

Answers (2)

ahgood
ahgood

Reputation: 1947

I use following code to add image header and footer, hope it helps.

Image path: /media/sales/store/logo/default/pdf_invoice_header.png /media/sales/store/logo/default/pdf_invoice_footer.png

File path: app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php (copied from app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php)

    ...
    protected function _drawHeader(Zend_Pdf_Page $page)
{
    /* Add table head */
    /* Custom Code Start */
    $header_image = Mage::getConfig()->getOptions()->getMediaDir().DS.'sales/store/logo/default/pdf_invoice_header.png';             
    if (is_file($header_image)) {
        $header_image = Zend_Pdf_Image::imageWithPath($header_image);
        $page->drawImage($header_image, 0, 767, 595, 842);
    }
    $footer_image = Mage::getConfig()->getOptions()->getMediaDir().DS.'sales/store/logo/default/pdf_invoice_footer.png';             
    if (is_file($footer_image)) {
        $footer_image = Zend_Pdf_Image::imageWithPath($footer_image);
        $page->drawImage($footer_image, 0, 10, 595, 60);
    }
    /* Custom Code End */
    ...

Upvotes: 0

Giuseppe
Giuseppe

Reputation: 219

Hy, the pdf for the invoice is printed by /app/code/core/Mage/Sales/Model/Order/invoice.pdf the logo printing function is in the abstract.pdf in the function insertLogo

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, 800, 125, 825);
        }
    }
    //return $page;
}

Of course make a local ovveride an start from there to modify the logo size and position. I don't know if the logo scaling is done during the upload, if yes you should first take care of the "scaling while uploading" issue.

bye Giuseppe

Upvotes: 1

Related Questions