From 42cd9778dc1c1c9f4298244a6ef93c8698745b6c Mon Sep 17 00:00:00 2001 From: blacktemplar Date: Tue, 18 Oct 2016 11:13:26 +0200 Subject: [PATCH] PDF options for row height paddings (#245) * added padding and content_padding options for pdf renderer * adds default padding and content_padding values * renames content_padding to contentPadding * adds option to specify height of header rows * fixes cs error --- config/module.config.php | 3 +++ src/ZfcDatagrid/Column/Action.php | 2 +- src/ZfcDatagrid/Renderer/TCPDF/Renderer.php | 13 +++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/module.config.php b/config/module.config.php index acfa9743..67dccb82 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -155,6 +155,7 @@ 'header' => [ 'font' => 'helvetica', 'size' => 11, + 'height' => 7, 'color' => [ 0, @@ -171,6 +172,8 @@ 'data' => [ 'font' => 'helvetica', 'size' => 11, + 'padding' => 4, + 'contentPadding' => 2, 'color' => [ 0, diff --git a/src/ZfcDatagrid/Column/Action.php b/src/ZfcDatagrid/Column/Action.php index 90609d7a..4f8e4b9a 100644 --- a/src/ZfcDatagrid/Column/Action.php +++ b/src/ZfcDatagrid/Column/Action.php @@ -76,7 +76,7 @@ public function removeAction($key = null) } /** - * + * */ public function clearActions() { diff --git a/src/ZfcDatagrid/Renderer/TCPDF/Renderer.php b/src/ZfcDatagrid/Renderer/TCPDF/Renderer.php index 3ab5285a..372f49aa 100644 --- a/src/ZfcDatagrid/Renderer/TCPDF/Renderer.php +++ b/src/ZfcDatagrid/Renderer/TCPDF/Renderer.php @@ -214,12 +214,15 @@ protected function getRowHeight(array $row) { $optionsRenderer = $this->getOptionsRenderer(); $sizePoint = $optionsRenderer['style']['data']['size']; + $padding = $optionsRenderer['style']['data']['padding']; + $contentPadding = $optionsRenderer['style']['data']['contentPadding']; + // Points to MM $size = $sizePoint / 2.83464566929134; $pdf = $this->getPdf(); - $rowHeight = $size + 4; + $rowHeight = $size + $padding; foreach ($this->getColumnsToExport() as $col) { /* @var $col \ZfcDatagrid\Column\AbstractColumn */ @@ -227,7 +230,7 @@ protected function getRowHeight(array $row) case 'ZfcDatagrid\Column\Type\Image': // "min" height for such a column - $height = $col->getType()->getResizeHeight() + 2; + $height = $col->getType()->getResizeHeight() + $contentPadding; break; default: @@ -246,7 +249,7 @@ protected function getRowHeight(array $row) $height = $pdf->getStringHeight($col->getWidth(), $value); // include borders top/bottom - $height += 2; + $height += $contentPadding; break; } @@ -260,6 +263,8 @@ protected function getRowHeight(array $row) protected function printTableHeader() { + $optionsRenderer = $this->getOptionsRenderer(); + $height = $optionsRenderer['style']['header']['height']; $this->setFontHeader(); $pdf = $this->getPdf(); @@ -275,7 +280,7 @@ protected function printTableHeader() $label = $this->translate($col->getLabel()); // Do not wrap header labels, it will look very ugly, that's why max height is set to 7! - $pdf->MultiCell($col->getWidth(), 7, $label, 1, $this->getTextAlignment(), true, 2, $x, $y, true, 0, false, true, 7); + $pdf->MultiCell($col->getWidth(), $height, $label, 1, $this->getTextAlignment(), true, 2, $x, $y, true, 0, false, true, 7); } }