Cubix Address Label Printing
4
5
13
13
Address too long hack
Very handy module, works in EE 1.11 fine
I added a quick and dirty hack for Aussies that others might like to modify.
Changes:
- Dropped country as we only ship locally
- Abbreviated State and put Post Code on same line
- Break address at 29 characters onto second line as we use a font size of 18
- Chop off long company names, limited to 29 chars
[code]
/* Draw shiping address */
$tempY = $this->y;
$tempX = $this->x;
$shippingAddress = $this->_formatAddress($order->getShippingAddress()->format('addresslabel'));
$this->y -= $this->_convertInchToPoints((float)$this->_config(self::XML_TOPPADDING));
$this->x += $this->_convertInchToPoints((float)$this->_config(self::XML_LEFTPADDING));
$firstLine = true;
// Modifications by FireHorse Dragonash @ FireHorse I.T.
$arraySize = count($shippingAddress);
if ($arraySize == 6) // if address array does not contain business name
{
$address = $shippingAddress[1];
$city = $shippingAddress[2];
$STATE_LONG = $shippingAddress[3];
$postCode = $shippingAddress[4];
}
elseif ($arraySize == 7) // if address array contains business name
{
$company_name = substr($shippingAddress[1], 0, 29); // change 29 to the length of company name to be shown
$address = $shippingAddress[2];
$city = $shippingAddress[3];
$STATE_LONG = $shippingAddress[4];
$postCode = $shippingAddress[5];
}
$long_address = 0;
if (strlen($address) > 30)
{
$long_address = 1;
$address_line1 = substr($address, 0, 28);
$address_line2 = substr($address, 28);
}
if ($STATE_LONG == "Queensland") {
$state = "QLD";
}
elseif ($STATE_LONG == "Northern Territory") {
$state = "NT";
}
elseif ($STATE_LONG == "Victoria") {
$state = "VIC";
}
elseif ($STATE_LONG == "New South Wales") {
$state = "NSW";
}
elseif ($STATE_LONG == "South Australia") {
$state = "SA";
}
elseif ($STATE_LONG == "Western Australia") {
$state = "WA";
}
elseif ($STATE_LONG == "Tasmania") {
$state = "TAS";
}
elseif ($STATE_LONG == "Australian Capital Territory") {
$state = "ACT";
}
if ($arraySize == 6) // no company name
{
if ($long_address == 1) // split address over 2 lines
{
$shippingAddress[1] = $address_line1 . "-";
$shippingAddress[2] = $address_line2;
$shippingAddress[3] = $city;
$shippingAddress[4] = $state . " " . $postCode; // put state and postcode on same line
}
else
{
$shippingAddress[1] = $address;
$shippingAddress[2] = $city;
$shippingAddress[3] = $state . " " . $postCode; // put state and postcode on same line
unset ($shippingAddress[4]);
}
unset ($shippingAddress[5]); // remove country line
}
elseif ($arraySize == 7) // address contains company name
{
if ($long_address == 1)
{
$shippingAddress[1] = $company_name;
$shippingAddress[2] = $address_line1 . "-";
$shippingAddress[3] = $address_line2;
$shippingAddress[4] = $city;
$shippingAddress[5] = $state . " " . $postCode; // put state and postcode on same line
}
else
{
$shippingAddress[1] = $company_name;
$shippingAddress[2] = $address;
$shippingAddress[3] = $city;
$shippingAddress[4] = $state . " " . $postCode; // put state and postcode on same line
unset ($shippingAddress[5]);
}
unset ($shippingAddress[6]); // remove country line
}
foreach ($shippingAddress as $value){
[/code]
April 18, 2013
utf-8 support
Have hack to add utf-8 support to this module
\app\code\local\Cubix\AddressLabel\Model\Pdf.php
find this code
protected function _setFontRegular($object, $size = 8)
{
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$object->setFont($font, $size);
return $font;
}
protected function _setFontBold($object, $size = 8)
{
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
return $font;
}
AND replace with this one
protected function _setFontRegular($object, $size = 8)
{
//Start edited to enable full utf-8 support for Hebrew lang. happyuserster@gmail.com
//$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . DS .'lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');
//! End edited to enable full utf-8 support for Hebrew lang. happyuserster@gmail.com
$object->setFont($font, $size);
return $font;
}
protected function _setFontBold($object, $size = 8)
{
//Start edited to enable full utf-8 support for Hebrew lang. happyuserster@gmail.com
//$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . DS .'lib\LinLibertineFont\LinLibertine_Bd-2.8.1.ttf');
//END edited to enable full utf-8 support for Hebrew lang. happyuserster@gmail.com
$object->setFont($font, $size);
return $font;
}
Tested working with
Languages:
Ukrainian
Russian
Hebrew
March 20, 2013
Hebrew text not printing on pdf file
extension support only english language.
Its not print Hebrew text on pdf.
The Hebrew Text is not displayed on the pdf file.
March 13, 2013
Hi,
After the installation I get the error message "Exception printing is disabled by default for security reasons" in the backend - I wasn't even able to clear cache any more. Just could reinstall my backup and uninstall the extension.
Any idea how to solve this?
Thanks!!!!
January 1, 2013
Hi, this extension is very usefull. I have a label that i use to adresses tha is 4.1in * 2.9in. I need that the label get printed with store details. I mean, left-top corner with my details and right-botton with the details of customer. Is this possible??
Thank you for share this fantastic extension.
Pedro
December 19, 2012
Very Exciting Extension. You are Cool!!!
December 14, 2012
Excellent extension, works great!
Currently doesn't work when https is enabled in the admin. There is a quick fix for this issue:
Open Cubix/ AddressLabel / Model / Observer.php
and replace the following line:
'url' => Mage::getUrl('addresslabeladmin/adminhtml_pdf/printLabel'),
with:
'url' => Mage::getUrl('addresslabeladmin/adminhtml_pdf/printLabel', array('_secure' => true )),
This will download the pdf on a secure url when https is switched on in the admin
October 26, 2012
It looks like a great and clean extension. It installs and configures without problems. After I clean all cheches and browser cookies and when I go to Orders and in Actions drop down - oops, Print Address Label command is missing. I tried to reinstall the module, uninstall it and install it again - the action in the dropdown is still missing. Can you please help? My Magento version is 1.6.1.0. Thank you in advance.
October 11, 2012
Great extension for Address in English
However, it is not usable for address in Chinese and Japanese
The Chinese and Japanese is not displayed on the pdf file
September 22, 2012
Works a treat, very little setup required and printing great looking labels out on my Zebra 2844.
September 10, 2012