diff --git a/src/Eccube/Service/OrderPdfService.php b/src/Eccube/Service/OrderPdfService.php index 9de9092b79b..f381520d248 100644 --- a/src/Eccube/Service/OrderPdfService.php +++ b/src/Eccube/Service/OrderPdfService.php @@ -648,8 +648,6 @@ protected function lfText($x, $y, $text, $size = 0, $style = '') /** * Colored table. * - * TODO: 後の列の高さが大きい場合、表示が乱れる。 - * * @param array $header 出力するラベル名一覧 * @param array $data 出力するデータ * @param array $w 出力するセル幅一覧 @@ -684,18 +682,9 @@ protected function setFancyTable($header, $data, $w) $this->SetFont(''); // Data $fill = 0; - $h = 4; - foreach ($data as $row) { - // 行のの処理 + $writeRow = function($row, $cellHeight, $fill, $isBorder) use($w) { $i = 0; - $h = 4; - $this->Cell(5, $h, '', 0, 0, '', 0, ''); - if ((277 - $this->getY()) < ($h * 4)) { - $this->checkPageBreak($this->PageBreakTrigger + 1); - } - - // Cellの高さを保持 - $cellHeight = 0; + $h = 0; foreach ($row as $col) { // 列の処理 // TODO: 汎用的ではない処理。この指定は呼び出し元で行うようにしたい。 @@ -705,8 +694,6 @@ protected function setFancyTable($header, $data, $w) // セル高さが最大値を保持する if ($h >= $cellHeight) { $cellHeight = $h; - } else { - $this->checkPageBreak($this->PageBreakTrigger + 1); } // 最終列の場合は次の行へ移動 @@ -716,18 +703,37 @@ protected function setFancyTable($header, $data, $w) $this->MultiCell( $w[$i], // セル幅 $cellHeight, // セルの最小の高さ - $col, // 文字列 - 1, // 境界線の描画方法を指定 + !$isBorder ? $col : '', // 文字列 + $isBorder ? 1 : 0, // 境界線の描画方法を指定 $align, // テキストの整列 $fill, // 背景の塗つぶし指定 - $ln // 出力後のカーソルの移動方法 + $ln // 出力後のカーソルの移動方法 ); $h = $this->getLastH(); + $i++; + } + return $cellHeight; + }; - ++$i; + foreach ($data as $row) { + // 行の処理 + $h = 4; + $this->Cell(5, $h, '', 0, 0, '', 0, ''); + if ((277 - $this->getY()) < ($h * 4)) { + $this->checkPageBreak($this->PageBreakTrigger + 1); } + + $x = $this->getX(); + $y = $this->getY(); + // 1度目は文字だけ出力し、行の高さ最大を取得 + $h = $writeRow($row, $h, $fill, false); + $this->setXY($x, $y); + // 2度目に最大の高さに合わせて、境界線を描画 + $writeRow($row, $h, $fill, true); + $fill = !$fill; } + $h = 4; $this->Cell(5, $h, '', 0, 0, '', 0, ''); $this->Cell(array_sum($w), 0, '', 'T'); $this->SetFillColor(255);