diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6ba5d446ecf..048c70e7f68 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1096,14 +1096,58 @@ abstract class CommonDocGenerator if (empty($columnText)) return; $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; + // save curent cell padding $curentCellPaddinds = $pdf->getCellPaddings(); - $pdf->setCellPadding(0); - $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); - $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + $pdf->writeHTMLCell($colDef['width'], 2, $colDef['xStartPos'], $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); + + // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } + + /** + * print standard column content + * + * @param TCPDF $pdf pdf object + * @param object $object CommonObject + * @param string $colKey the column key + * @param $i + * @param $outputlangs + * @param float $curY curent Y position + * @param $hideref + * @param $hidedesc + * @param $issupplierline + */ + function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0){ + // load desc col params + $colDef = $this->cols[$colKey]; + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + + // line description + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $colDef['width'], 3, $colDef['xStartPos'], $curY, $hideref, $hidedesc, $issupplierline); + $posYAfterDescription = $pdf->GetY() - $colDef['content']['padding'][0]; + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, $colKey, $extrafieldDesc); + } + } + /** * get extrafield content for pdf writeHtmlCell compatibility * usage for PDF line columns and object note block diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3c914dbd478..224f3522382 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -584,7 +584,7 @@ class pdf_sponge extends ModelePDFFactures $iniY = $tab_top + $this->tabTitleHeight + 2; $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 2; + $nexY = $tab_top + $this->tabTitleHeight + 0; // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); @@ -637,37 +637,15 @@ class pdf_sponge extends ModelePDFFactures if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - - // Display extrafield if needed - - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); @@ -695,7 +673,6 @@ class pdf_sponge extends ModelePDFFactures { $pdf->commitTransaction(); } - $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); @@ -848,12 +825,10 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY += 2; // Add space between lines - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); @@ -2242,7 +2217,7 @@ class pdf_sponge extends ModelePDFFactures // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -2279,10 +2254,11 @@ class pdf_sponge extends ModelePDFFactures 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); @@ -2429,4 +2405,5 @@ class pdf_sponge extends ModelePDFFactures $this->cols = $hookmanager->resArray; } } + }