Magento:PHP到PDF发票-创建新行/换行内容
我正在编辑我的发票文件Magento:PHP到PDF发票-创建新行/换行内容,php,magento,pdf,pdf-generation,magento-1.5,Php,Magento,Pdf,Pdf Generation,Magento 1.5,我正在编辑我的发票文件 /Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php 我遇到了一个问题:如果其他栏目的内容很长,那么这些栏目就会与之重叠。例如,产品说明将在下一列中列出。我正试图找出如何限制宽度/换行/为内容创建新行 代码是: // draw Product name $lines[0] = array(array( 'text' => Mage::helper('core/string')->str_split
/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中都是“绝对”的,则几乎等于左边距)
但我不确定如何限制它们的宽度和文字包装,这样如果我有一个较长的制造商,它就不会出现这种颜色。发票上没有足够的空间来为每个属性提供更多的空间。答案就在这里:
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => 35,
));
这里的60是每行显示的字符数
->getName(),60,true,
答案就在这里:
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => 35,
));
这里的60是每行显示的字符数
->getName(),60,true,
我也有同样的问题。当我添加一个新列时,ProductDescription列消失了。我通过减少$productDescr的stru split函数中的一个数字(长度)来解决这个问题。我也遇到了同样的问题。当我添加一个新列时,ProductDescription列消失了。我通过减少$productDescr的str_split函数中的一个数字(长度)来解决这个问题