1

The order and invoice numbers are hard to read on my printed mangento invoices. I want to change the header from the white on dark grey default to plain old black on white. Can anyone point me to the right place to update this?

I was looking in the invoice.php file in Mage\Sales\Model\Order\Pdf but while there appear to be some items from this printed report in there... I cannot see anything having to do with the header.

Thanks

4

2 回答 2

7

The file you are looking for is app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php. I have marked the two lines you'll need to change with // <--. The documentation for Zend_Pdf_Color_GrayScale will tell you that 0.0 is black, 1.0 is white.

protected function insertOrder(&$page, $obj, $putOrderId = true)
{
    if ($obj instanceof Mage_Sales_Model_Order) {
        $shipment = null;
        $order = $obj;
    } elseif ($obj instanceof Mage_Sales_Model_Order_Shipment) {
        $shipment = $obj;
        $order = $shipment->getOrder();
    }

    /* @var $order Mage_Sales_Model_Order */
    $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));  // <-- White header

    $page->drawRectangle(25, 790, 570, 755);

    $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));  // <-- Black text
    $this->_setFontRegular($page);

    if ($putOrderId) {
        $page->drawText(Mage::helper('sales')->__('Order # ').$order->getRealOrderId(), 35, 770, 'UTF-8');
    }
    $page->drawText(Mage::helper('sales')->__('Order Date: ') . Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'medium', false), 35, 760, 'UTF-8');

Additional information (discovered when making this change):

Be aware that the Creditmemo, Invoice, and shipment all share the same basic header from the Abstract file. So when you change the background color of the abstract file there is a line containing the Shipment #, Invoice # or Credit Memo # that is printed in each of the following files that you will also need to address.

The default font color is white and so changing the abstrat background header to white creates a white on white (hence invisible) result.

In the Creditmemo.php, Invoice.php, and Shipment.php files in that same directory find the following line (almost identical across the 3 files) and update it as well.

public function getPdf($shipments = array())
{
    // .... a few lines of code .....  //

    /* Add head */
    $this->insertOrder($page, $shipment, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId()));

    // 0 to print black, 1 to print white
    $page->setFillColor(new Zend_Pdf_Color_GrayScale(1)); 
    $this->_setFontRegular($page);
于 2012-04-20T03:46:07.173 回答
4

Just a heads up to anyone looking for this answer but not able to find the code to change in Invoice.php, Shipping.php etc.

Im my Magento Version 1.7.0.2 to change the top title invoice number I also made this change in the Abstract.php file around line 512.

` public function insertDocumentNumber(Zend_Pdf_Page $page, $text)
    {
        $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));`

Just wanted to share as I personally wasted too much time on this and hope to save the next person some.

于 2013-02-12T17:34:22.877 回答