我只是试图在Magento 2.3的发票标签中添加额外的折扣列,但是在添加后,我的整个发票列都变得相互重叠。因此,我的问题是如何固定列宽,以使一列中的重叠文本位于该列行的底部。
这是Magento\Sales\Model\Order\Pdf
中的_drawHeader函数的代码
/**
* Draw header for item table
*
* @param \Zend_Pdf_Page $page
* @return void
*/
protected function _drawHeader(\Zend_Pdf_Page $page)
{
/* Add table head */
$this->_setFontRegular($page, 10);
$page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
$page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.5));
$page->setLineWidth(0.5);
$page->drawRectangle(25, $this->y, 570, $this->y - 15);
$this->y -= 10;
$page->setFillColor(new \Zend_Pdf_Color_Rgb(0, 0, 0));
//columns headers
$lines[0][] = ['text' => __('Products'), 'feed' => 35];
$lines[0][] = ['text' => __('SKU'), 'feed' => 220, 'align' => 'center'];
$lines[0][] = ['text' => __('Price'), 'feed' => 355, 'align' => 'center'];
$lines[0][] = ['text' => __('Qty'), 'feed' => 420, 'align' => 'center'];
// Add extra Discount field
$lines[0][] = ['text' => __('Discount'), 'feed' => 440, 'align' => 'center'];
$lines[0][] = ['text' => __('Tax'), 'feed' => 480, 'align' => 'center'];
$lines[0][] = ['text' => __('Subtotal'), 'feed' => 520, 'align' => 'center'];
$lineBlock = ['lines' => $lines, 'height' => 5];
$this->drawLineBlocks($page, [$lineBlock], ['table_header' => true]);
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$this->y -= 20;
}