【发布时间】:2012-12-16 23:25:34
【问题描述】:
我正在编辑我的发票文件
/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 术语中都是“绝对的”,则几乎 = 到左边距)。
但我不确定如何限制它们的宽度和自动换行,这样如果我的制造商很长,它就不会碰到颜色。发票上没有足够的空间来简单地为每个属性提供更多空间。
【问题讨论】:
标签: php magento pdf pdf-generation magento-1.5