Skip to content
sprankhub edited this page Nov 7, 2014 · 12 revisions

Logo

Where Can I Upload a Logo Which Is Shown On the Documents?

Upload your logo in the backend:

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

How Can I Add A Footer Without Using GermanSetup/MageSetup?

One possibility is to put the following XML into your own module:

<config>
    <default>
        <general>
            <imprint>
                <company_first>...</company_first>
                <company_second>...</company_second>
                <street>...</street>
                <zip>...</zip>
                <city>Musterstadt</city>
                <country>Musterland</country>
                <telephone>...</telephone>
                <fax>...</fax>
                <email>...</email>
                <web>...</web>
                <bank_name>...</bank_name>
                <bank_account>...</bank_account>
                <bank_code_number>...</bank_code_number>
                <bank_account_owner>...</bank_account_owner>
                <swift>...</swift>
                <iban>...</iban>
                <tax_number>...</tax_number>
                <vat_id>...</vat_id>
                <register_number>...</register_number>
                <ceo>...</ceo>
            </imprint>
        </general>
    </default>
</config>

You could also write these values into the database table core_config_data directly, although I would not recommend that.

How Can I Change or Remove Elements from the Imprint?

In your module's config.xml, you can define an observer on the event firegento_pdf_imprint_load_after. Example:

    <firegento_pdf_imprint_load_after>
        <observers>
            <namespace_module>
                <class>namespace_module/observer</class>
                <method>firegentoPdfImprintLoadAfter</method>
            </namespace_module>
        </observers>
    </firegento_pdf_imprint_load_after>

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

<?php
class Namespace_Module_Observer
{

    /**
     * Change the imprint somehow
     *
     * @param  Varien_Event_Observer $observer observer object
     *
     * @return $this
     */
    public function firegentoPdfImprintLoadAfter(Varien_Event_Observer $observer)
    {
        $transportObject = $observer->getEvent()->getTransportObject();
        $imprint = $transportObject->getImprint();
        // do some fancy stuff with the imprint array
        unset($imprint['tax_number']);
        $transportObject->setImprint($imprint);
        return $this;
    }

}
Clone this wiki locally