我在
中编辑我的发票文件/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php
如果列内容很长,我遇到的问题是列会运行并重叠其他列。例如,在下一列上运行的产品描述。我正在试图弄清楚如何限制宽度/自动换行/为内容创建一个新行。
代码是:
// draw Product name
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => 35,
));
// draw SKU
// $lines[0][] = array(
// 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
// 'feed' => 255
// );
// draw Brand (Added by James)
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('manufacturer'));
if ($product) {
$lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($product->getAttributeText('manufacturer'), 15),
'feed' => 220
);
}
// draw Colour (Added by James)
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('pos_short_colour'));
if ($product) {
$lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($product->getAttributeText('pos_short_colour'), 15),
'feed' => 320
);
}
我知道'feed'用于设置数组从左边开始的距离(相当于一个边距 - 如果所有项目都是css术语中的'绝对')。
但是我不确定如何限制它们的宽度和自动换行,这样如果我有一个很长的制造商它就不会遇到这种颜色。发票上没有足够的空间来简单地为每个属性提供更多空间。
答案 0 :(得分:1)
答案就在那里:
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => 35,
));
这里的60是每行显示多少个字符->getName(), 60, true,
答案 1 :(得分:0)
我有同样的问题。添加新列时,“产品说明”列消失了。我通过减少$ productDescr的str_split函数中的数字(长度)来解决这个问题。