Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Edit the styling of the PDF Invoice print outs
 
dunce
Member
 
Total Posts:  33
Joined:  2009-09-12
 

Mostly i would like to change the dark bar at the top. We print our invoices and this seems like a really bad decision by magento to make such a dark header bar at the top.

I edited line71 of app/code/core/Mage/Sales/Model/Order/PDF/Invoice.php from 0.93,0.92,0.92 to 1.0,1.0,1.0 to be white.. but it isnt working

my current invoice.php looks like:

class Mage_Sales_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Abstract
{
    
public function getPdf($invoices = array())
    
{
        $this
->_beforeGetPdf();
        
$this->_initRenderer('invoice');

        
$pdf = new Zend_Pdf();
        
$this->_setPdf($pdf);
        
$style = new Zend_Pdf_Style();
        
$this->_setFontBold($style10);

        foreach (
$invoices as $invoice{
            
if ($invoice->getStoreId()) {
                Mage
::app()->getLocale()->emulate($invoice->getStoreId());
            
}
            $page 
$pdf->newPage(Zend_Pdf_Page::SIZE_A4);
            
$pdf->pages[] $page;

            
$order $invoice->getOrder();

            
/* Add image */
            
$this->insertLogo($page$invoice->getStore());

            
/* Add address */
            
$this->insertAddress($page$invoice->getStore());

            
/* Add head */
            
$this->insertOrder($page$orderMage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID$order->getStoreId()));


            
$page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
            
$this->_setFontRegular($page);
            
$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35780'UTF-8');

            
/* Add table */
            
$page->setFillColor(new Zend_Pdf_Color_RGB(1.01.01.0));
            
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
            
$page->setLineWidth(0.5);

            
$page->drawRectangle(25$this->y570$this->-15);
            
$this->-=10;

            
/* Add table head */
            
$page->setFillColor(new Zend_Pdf_Color_RGB(0.40.40.4));
            
$page->drawText(Mage::helper('sales')->__('Products'), 35$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('SKU'), 255$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Price'), 380$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Qty'), 430$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Tax'), 480$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Subtotal'), 535$this->y'UTF-8');

            
$this->-=15;

            
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));

            
/* Add body */
            
foreach ($invoice->getAllItems() as $item){
                
if ($item->getOrderItem()->getParentItem()) {
                    
continue;
                
}

                
if ($this->15{
                    $page 
$this->newPage(array('table_header' => true));
                
}

                
/* Draw item */
                
$page $this->_drawItem($item$page$order);
            
}

            
/* Add totals */
            
$page $this->insertTotals($page$invoice);

            if (
$invoice->getStoreId()) {
                Mage
::app()->getLocale()->revert();
            
}
        }

        $this
->_afterGetPdf();

        return 
$pdf;
    
}

    
/**
     * Create new page and assign to PDF object
     *
     * @param array $settings
     * @return Zend_Pdf_Page
     */
    
public function newPage(array $settings = array())
    
{
        
/* Add new table head */
        
$page $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
        
$this->_getPdf()->pages[] $page;
        
$this->800;

        if (!empty(
$settings['table_header'])) {
            $this
->_setFontRegular($page);
            
$page->setFillColor(new Zend_Pdf_Color_RGB(1.01.01.0));
            
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
            
$page->setLineWidth(0.5);
            
$page->drawRectangle(25$this->y570$this->y-15);
            
$this->-=10;

            
$page->setFillColor(new Zend_Pdf_Color_RGB(0.40.40.4));
            
$page->drawText(Mage::helper('sales')->__('Product'), 35$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('SKU'), 255$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Price'), 380$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Qty'), 430$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Tax'), 480$this->y'UTF-8');
            
$page->drawText(Mage::helper('sales')->__('Subtotal'), 535$this->y'UTF-8');

            
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
            
$this->-=20;
        
}

        
return $page;
    
}
}

any help please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
erenaud
Sr. Member
 
Total Posts:  221
Joined:  2009-01-05
Minden, Germany
 

I am not a coder, so I only have this hint: we are using the Fooman PDF customiser. search for it in magento connect.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dunce
Member
 
Total Posts:  33
Joined:  2009-09-12
 

Really hoping for a non-paid option + im having magento connect issues… is there nothing i can edit myself? anyone…

 
Magento Community Magento Community
Magento Community
Magento Community
 
mooooo
Jr. Member
 
Total Posts:  16
Joined:  2010-07-10
 

Have a look in /mage/sales/model/order/pdf/abstract.php

There’s another PDF editing module which has a one-line edit for the color of the rectangles in the packing sheet:
pdf customizer

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

I have another questions regarding the pdf layout: is it possible to draw a rectangle around the otdered items list? If we can somehow define the dynamic height of the entries (since it obviously differs from order to order), we could use this - but I don’t know how.

Did anybody manage something like this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
moomoo
Sr. Member
 
Avatar
Total Posts:  192
Joined:  2009-07-10
 

@loeffel - you could just count the lines of output to get the end coordinates of your rectangle; the start points could be worked out from the start points of your text. (you can also change the colours in my pdf extension, pickPack)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top