Printing a removable customer address label from Magento

With the invoice and packing slip software for Magento you can include the following information onto a document with peel off labels to stick to your parcels or letters:

1 Customer invoice and delivery addresses
2 Returns address
3 Loyalty details (or any other text you want to use)
Works with
UK Magento up to 1.69, 1.7,, 1.9, 2, 2.27
Please contact us if your version of the software is not supported

Because the label is on the same document that you pick and pack from it improves the efficiency of your packing process and saves you time. There is also less chance of the wrong goods being sent to the customer. There are no new Magento procedures to learn as you print your invoice or packing slip in the same way that you currently do, shown below:

Invoices and Packing Slips are provided for single and double label paper. If you are using double perforated paper you can tear off the top addresses section.

Examples of all the Invoice and Packing Lists available are shown below. See the Advanced Features section on how to change the address format on the labels (e.g. to put the postcode on a separate line)

Invoice with delivery address at bottom left on single label paper

Invoice with delivery address at bottom left and invoice address at bottom right on double label paper. If using double perforated paper the bottom section can be removed.
Packing Slip with delivery address at bottom left on single label paper
Packing Slip with delivery address at bottom left and invoice address at bottom right on double label paper. If using double perforated paper the bottom section can be removed.

You can also design the text shown on the second label during the installation of the software:

Adding a custom Integrated Label format to Magento (optional)

The supplied templates should be fine for most installations of Magento and will work correctly.

If you want more flexibility over how addresses are formatted or have a special requirement for address formatting you can install a new address format into Magento. If you are using Magento 1.8 or above you can also configure this using the Administrator account in the Customer Configuration page (by selecting System->Configuration menu option and then the Customer Configuration option on the left hand side). There will be a new address format box called Integrated Label, shown below:

If you are using an earlier version (than 1.8) you can still configure the address, using the approach described in the Advanced Features section. The formatting of the address is described in the Advanced Features section

How to install the custom Integrated Label format into Magento

NOTE: This will require changing some of your system configuration files in your Magento Installation

This guide discusses putting changes into files in the core area of Magento. Your System Administrator may want you to put changes into the local area of Magento (to keep changes between Magento upgrades). If you want to do this if you contact your system administrator.

In your installation n the


folder take a backup of the config.xml and system.xml files.

2 In the config.xml file find the 2 consecutive lines


after these lines and just before the


line add the following lines:

<int_lab template="title" module="customer">
<title>Integrated Label</title>

If you now look for the line


Just after this line if you add

<int_lab><![CDATA[{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}|{{depend company}}{{var company}}|{{/depend}}{{if street1}}{{var street1}}{{/if}} {{depend street2}}{{var street2}}|{{/depend}}{{depend street3}}{{var street3}}|{{/depend}}{{depend street4}}{{var street4}}|{{/depend}}{{if city}}{{var city}},|{{/if}}{{if region}}{{var region}},|{{/if}}{{if postcode}}{{var postcode}}{{/if}}|{{var country}}]]></int_lab>

If you now save and close this file.

3 If you using version 1.8 or higher of Magento you can add this to the interface by doing the following:

In the system.xml file If you look for the 2 lines


and just before these lines add

<label>Integrated Label</label>

Save and close this file.

4 Because you have added a new custom address format into Magento you will have to change the supplied invoice template to use the new format type. To do this open the supplied invoice. php file

Remove the following line from the file

$curr_line += 1;

Find the line

$shippingAddress = $this->FormatAddressLabel($order->getShippingAddress()->format('pdf'), 40);

$billingAddress = $this->FormatAddressLabel($order->getBillingAddress()->format('pdf'), 40);

and change the pdf to int_lab to use the address formatting. The lines should now look like:

$shippingAddress = $this->FormatAddressLabel($order->getShippingAddress()->format('int_lab'), 40);

$billingAddress = $this->FormatAddressLabel($order->getBillingAddress()->format('int_lab'), 40);

NOTE: You may not have both lines in the file depending on which invoice template you installed.

Save and close this file

5 You should now clear your Magento cache (explained in the Advanced Features section) and you should now be able to print invoices using the new format.

Advanced Features

Line of text on lanel is too wide or too short
The supplied invoices and packing slips wrap the lines at 40 characters. If you want to change this line width amend the invoice.php or packingslip.php file and look for calls to FormatAddressLabel. The last value is the maximum width of each line before starting a new line on the label. For example, to change the maximum line width to 40 characters change the call to

$this->FormatAddressLabel($order->getShippingAddress()->format('pdf'), 50);

Parts of address need to be put onto separate lines (e.g. postcode)
By default Magento displays addresses in the following format:

Customer Name,
Address Line 1, Address Line 2
Address Line 3, Town, Post Code

For example,

Emily Took Brown
The Larches, Appletonea
Monkton, ZZ1 1ES
United Kingdom

You can change the format by using the approach shown below. For example, to put the postcode onto a separate line, shown below:

Emily Took Brown
The Larches, Appletonea
United Kingdom

If you are using one of the newer Magento versions you can change the format in the Configuration options, if this isn't available use item 4 onwards.

1 Select the System->Configuration menu option.

On the left hand side if you click on Customer Configuration.

In the Address Templates section amend the values in the PDF section. This is described below in item 6.

4 On your website open the file app/code/core/Mage/Customer/etc/config.xml

Find the section called pdf (look for the word pdf). You will find the line shown below:

<pdf translate="title" module="customer">

6 The text after this describes how to layout the addresses. To put text onto a new line use a | character. For example, to put the postcode onto its own line change

{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}|


{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}| {{/if}}{{if postcode}}{{var postcode}}{{/if}}|

NOTE: The address description may be slightly different than that shown above for different Magento versions.

Adding a PPI to the label
You can add a PPI by adding the following lines after the code that draws the label (in the section).

$image = Mage::getConfig()->getOptions()->getMediaDir().DS.'PPIImage.jpg';
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, 190, 168, 290, 207);

You will need to put the image in the /public_html/media/ folder on your website. The PPI image should be 207 by 83 pixels.

Adding a logo to the label
You can add a logo by adding the following lines after the code that draws the label (or PPI) (in the section).

$image = Mage::getConfig()->getOptions()->getMediaDir().DS.'IL_logo.jpg';
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, 70, 181, 145, 207);

You will need to put the image in the /public_html/media/ folder on your website. In this example, The logo is 245 by 85 pixels.

Resolving problems
If the address details don't change format on the label the following should resolve this:

1 Do you have a copy of the configuration file at:

app/code/local/Mage/Customer/etc/config.xml ?

If you do you should amend this version as this file is picks up before the core files.

2 Have you cleared the Magento Cache (System > Cache Management)?

If the return address does not print correctly

Are there any ' (apostophe) characters in the return address details (e.g. Goat's shed House). There are 2 possible solutions:

1 Use a different character (e.g. Goat`s shed House)

2 Change the text in the file to use a " around the text (e.g. $page->drawText{"Goat's shed House"...).

Mole End Group of Companies
Products, plugins and utilities for Actinic Desktop and SellerDeck All your orders, from all your systems, all together in one simple-to-use application Integrated label invoice paper and free software packages and templates. Print your invoice and labels at the same time Print Amazon Despatch Notes with a peel out label with the customer's details on directly from Amazon Print Ebay Invoices with a peel out label with the customer's details on directly from Ebay