Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX : DEVELOP pdf space lost with images at bottom of Cyan PDF #31273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6240246
Fix space lost at bottom of page when PDF use product images
thersane-john Oct 4, 2024
498e147
Rebuild Cyan PDF MODEL
thersane-john Oct 8, 2024
377d211
Merge branch '20.0' of https://github.com/Dolibarr/dolibarr into fix_…
thersane-john Oct 8, 2024
9ace804
Clean useless lines
thersane-john Oct 9, 2024
1a909f8
Fix duplicate head print in first page of line loop display
thersane-john Oct 9, 2024
b79fa55
fix phan
thersane-john Oct 9, 2024
0dfda86
fix phan
thersane-john Oct 9, 2024
ebc5182
fix phan
thersane-john Oct 9, 2024
35ffdda
fix phan
thersane-john Oct 9, 2024
7c0e47c
fix phan
thersane-john Oct 9, 2024
901ce66
Clean code and fix artifact
thersane-john Oct 9, 2024
42ce032
Clean code and fix artifact
thersane-john Oct 9, 2024
c2d381d
Merge branch '20.0' into fix_v20_pdf_space_lost_with_images
eldy Oct 17, 2024
1852e13
fix page orientation
thersane-john Oct 17, 2024
68df2bf
Merge branch '20.0' of https://github.com/Dolibarr/dolibarr into fix_…
thersane-john Oct 18, 2024
702ff5a
fix usage of on bottom
thersane-john Oct 18, 2024
e53858a
fix usage of on bottom
thersane-john Oct 18, 2024
2b85f40
Fix breaks on edge
thersane-john Oct 21, 2024
21aa2f6
Merge branch '20.0' into fix_v20_pdf_space_lost_with_images
thersane-john Oct 22, 2024
8a6119b
Image top margin
thersane-john Oct 24, 2024
7649166
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into f…
thersane-john Oct 24, 2024
b7f85ff
fix precommit hook
thersane-john Oct 24, 2024
aea4f2c
fix php stan
thersane-john Oct 24, 2024
5fc526b
fix php stan
thersane-john Oct 24, 2024
b188f93
Merge branch 'develop' into fix_v20_pdf_space_lost_with_images
thersane-john Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions htdocs/core/class/commondocgenerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ abstract class CommonDocGenerator
*/
public $cols;

/**
* @var array<string,array{page:int,y:float|int}> Array of position data
*/
public $afterColsLinePositions;

/**
* @var array{fullpath:string} Array with result of doc generation. content is array('fullpath'=>$file)
*/
Expand Down Expand Up @@ -1250,6 +1255,64 @@ public function printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebo
}
}

/**
* Get position in PDF after col display
* @return false|array{page:int,y:float|int,col:string}
*/
public function getMaxAfterColsLinePositionsData()
{
if (empty($this->afterColsLinePositions) || !is_array($this->afterColsLinePositions)) {
return false;
}

$colId = '';
$maxPage = $maxY = 0;
foreach ($this->afterColsLinePositions as $colKey => $value) {
if ($value['page'] > $maxPage) {
$colId = $colKey;
$maxPage = $value['page'];
$maxY = $value['y']; // if page is higher we need to reset y to new max page y
} elseif ($value['page'] == $maxPage) {
$maxY = max($value['y'], $maxY);
$colId = $colKey;
}
}

return [
'col' => $colId,
'y' => $maxY,
'page' => $maxPage
];
}

/**
* Used for reset afterColsLinePositions var in start of a new pdf draw line loop
* @param float $y the new $y position usually get by TCPDF::GetY()
* @param int $pageNumb the page number to reset at
* @return void
*/
public function resetAfterColsLinePositionsData(float $y, int $pageNumb)
{
$this->afterColsLinePositions = [];
$this->setAfterColsLinePositionsData('startLine', $y, $pageNumb);
}

/**
* Used for to set afterColsLinePositions var in a pdf draw line loop
* @param string $colId the column id used as key in $this->cols or an unique id code like startLine or separateLine ....
* @param float $y the $y position usually get by TCPDF::GetY() where print data ended
* @param int $pageNumb the page number where print data ended
* @return void
*/
public function setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)
{
$this->afterColsLinePositions[$colId] = [
'page' => $pageNumb,
'y' => $y
];
}


/**
* uasort callback function to Sort columns fields
*
Expand Down Expand Up @@ -1463,6 +1526,7 @@ public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '')
// set cell padding with column content definition
$pdf->setCellPaddings(isset($colDef['content']['padding'][3]) ? $colDef['content']['padding'][3] : 0, isset($colDef['content']['padding'][0]) ? $colDef['content']['padding'][0] : 0, isset($colDef['content']['padding'][1]) ? $colDef['content']['padding'][1] : 0, isset($colDef['content']['padding'][2]) ? $colDef['content']['padding'][2] : 0);
$pdf->writeHTMLCell($colDef['width'], 2, isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0, $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']);
$this->setAfterColsLinePositionsData($colKey, $pdf->GetY(), $pdf->getPage());

// restore cell padding
$pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']);
Expand Down
Loading
Loading