Skip to content
Fabian Blechschmidt edited this page May 10, 2014 · 12 revisions

Logo

Where to upload the logo to show on the invoice?

Upload your logo in the backend here:

System > Config > SALES > Sales > Invoice and Packing Slip Design > Logo for PDF Print-outs (200x50)

How Can I Add Notes to the PDFs?

You can define custom notes for invoices, shipments and credit memos under System - Configuration - Sales PDF - Invoice/Shipment/Credit Memo - Note. You can also add notes programmatically:

How Can I Add Notes to the PDFs Programmatically?

In your module's config.xml, you define an observer on the event firegento_pdf_invoice_insert_note, firegento_pdf_shipment_insert_note or firegento_pdf_creditmemo_insert_note respectively. Example:

    <firegento_pdf_invoice_insert_note>
        <observers>
            <namespace_module>
                <class>namespace_module/observer</class>
                <method>addMyFunkyNote</method>
            </namespace_module>
        </observers>
    </firegento_pdf_invoice_insert_note>

Then you create your Module/Observer.php file with the following code:

<?php
class Namespace_Module_Observer
{

    /**
     * Add my super funky note
     *
     * @param  Varien_Event_Observer $observer observer object
     *
     * @return $this
     */
    public function addMyFunkyNote(Varien_Event_Observer $observer)
    {
        $result = $observer->getResult();
        $notes = $result->getNotes();
        $notes[] = 'My super funky note';
        $result->setNotes($notes);
        return $this;
    }

}

That's it to add your super funky note to one of the PDFs!

How Can I Put Some Fancy Stuff Wherever I Want To Without Writing My Own Engine?

In your module's config.xml, you define an observer on the event firegento_pdf_invoice_edit_page, firegento_pdf_shipment_edit_page or firegento_pdf_creditmemo_edit_page respectively. Example:

    <firegento_pdf_invoice_edit_page>
        <observers>
            <namespace_module>
                <class>namespace_module/observer</class>
                <method>addFancyStuff</method>
            </namespace_module>
        </observers>
    </firegento_pdf_invoice_edit_page>

Then you create your Module/Observer.php file with the following code:

<?php
class Namespace_Module_Observer
{

    /**
     * Add my super fancy stuff
     *
     * @param  Varien_Event_Observer $observer observer object
     *
     * @return $this
     */
    public function addFancyStuff(Varien_Event_Observer $observer)
    {
        $page = $observer->getPage();
        $page->drawText('This is really super fancy!', 200, 200, 'UTF-8');
        return $this;
    }

}

I Do Not Like The Standard Engines - How Can I Write My Own Engine?

Create a module and put this into the global namespace:

    <global>
        <models>
            <mymodule>
                <class>MyNamespace_MyModule_Model</class>
            </mymodule>
        </model>
        <pdf>
            <firegento_invoice_engines>
                <mymodule_default>
                    <class>mymodule/firegento_pdf_engine_invoice_default</class>
                    <label>Standard MyModule</label>
                </mymodule_default>
            </firegento_invoice_engines>
            <firegento_shipment_engines>
                <mymodule_default>
                    <class>mymodule/firegento_pdf_engine_shipment_default</class>
                    <label>Standard MyModule</label>
                </mymodule_default>
            </firegento_shipment_engines>
            <firegento_creditmemo_engines>
                <mymodule_default>
                    <class>mymodule/firegento_pdf_engine_creditmemo_default</class>
                    <label>Standard MyModule</label>
                </mymodule_default>
            </firegento_creditmemo_engines>
        </pdf>
    </global>

Create the three Default classes in their respective folder below MyNamespace/MyModule/Model/Firegento/Pdf/Engine/ and copy the contents of the FireGento_Pdf classes (please note: I haven't found any other way to do this). Then create the abstract class in MyNamespace/MyModule/Model/Firegento/Pdf/Engine/Abstract.php and overwrite whatever function you need from the base class. For instance, if you want to strip out the logo, sender address bar and footer because the client uses some custom paper where these information is already printed you may use this class:

<?php

abstract class MyNamespace_MyModule_Model_Firegento_Pdf_Engine_Abstract
extends FireGento_Pdf_Model_Engine_Abstract
{
    /**
     * Insert sender address bar.
     *
     * @param Zend_Pdf_Page $page Current page object of Zend_Pdf
     * @return void
     */
    protected function _insertSenderAddessBar(&$page)
    {
        // Do not print sender address bar
    }

    /**
     * Insert logo
     *
     * @param Zend_Pdf_Page $page Current page object of Zend_Pdf
     * @param mixed $store
     * @return void
     */
    protected function insertLogo(&$page, $store = null)
    {
        // Do not print logo
    }

    /**
     * Insert footer
     *
     * @param Zend_Pdf_Page $page Current page object of Zend_Pdf
     * @return void
     */
    protected function _insertFooter(&$page)
    {
        // Do not print footer
    }
}
Clone this wiki locally