fix disable filigran

This commit is contained in:
Tolotsoa 2025-08-29 11:28:40 +03:00
parent 486357834b
commit b2ff0cc6bd
2 changed files with 91 additions and 73 deletions

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service\InvoiceGroupPdfHandler; namespace OCA\Gestion\Service\InvoiceGroupPdfHandler;
use DateTime; use DateTime;
use \FPDF; use FPDF;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
@ -54,11 +54,11 @@ class InvoiceGroupPdfHandler extends FPDF
public $additionalArticlesLineBasedOnMultiline = 0; public $additionalArticlesLineBasedOnMultiline = 0;
public $interLigneHeader = 5; public $interLigneHeader = 5;
function Header() public function Header()
{ {
if ($this->logo != "nothing") { if ($this->logo != "nothing") {
$this->Image($this->logoPath . "logo.png", 4, 2, 50, 35); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
$this->AddWatermark(); //$this->AddWatermark();
} else { } else {
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
@ -66,7 +66,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable(); $this->DrawInvoiceInfoTable();
} }
function AddWatermark() public function AddWatermark()
{ {
try { try {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
@ -74,29 +74,29 @@ class InvoiceGroupPdfHandler extends FPDF
$imagePath = $this->logoPath . "filigrane_pdf.png"; $imagePath = $this->logoPath . "filigrane_pdf.png";
list($originalWidth, $originalHeight) = getimagesize($imagePath); list($originalWidth, $originalHeight) = getimagesize($imagePath);
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
$originalWidth = $originalWidth * 0.264583; $originalWidth = $originalWidth * 0.264583;
$originalHeight = $originalHeight * 0.264583; $originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine // Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 1.7; $scale = 1.7;
$width = $originalWidth * $scale; $width = $originalWidth * $scale;
$height = $originalHeight * $scale; $height = $originalHeight * $scale;
// Calculer la position pour centrer l'image // Calculer la position pour centrer l'image
$x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm $x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm
$y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4 $y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4
// Ajouter l'image en filigrane // Ajouter l'image en filigrane
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur $this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
$this->SetAlpha(0.1); // Définir l'opacité $this->SetAlpha(0.1); // Définir l'opacité
} catch (\Throwable $th) { } catch (\Throwable $th) {
} }
} }
function SetAlpha($alpha) public function SetAlpha($alpha)
{ {
// Appliquer la transparence au document // Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255); $this->SetFillColor(255, 255, 255, $alpha * 255);
@ -111,7 +111,7 @@ class InvoiceGroupPdfHandler extends FPDF
} }
function Footer() public function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('Arial', '', 7); $this->SetFont('Arial', '', 7);
@ -300,7 +300,7 @@ class InvoiceGroupPdfHandler extends FPDF
// les traits verticaux colonnes // les traits verticaux colonnes
$additionalMargRight = 1; $additionalMargRight = 1;
$endingLine = 233 + $additionnalheight; $endingLine = 233 + $additionnalheight;
$this->Line( 27 + $additionalMargRight, $this->startingYOfArticlesTable, 27 + $additionalMargRight, $endingLine); $this->Line(27 + $additionalMargRight, $this->startingYOfArticlesTable, 27 + $additionalMargRight, $endingLine);
$this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142 + $additionalMargRight, $endingLine); $this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142 + $additionalMargRight, $endingLine);
$this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164 + $additionalMargRight, $endingLine); $this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164 + $additionalMargRight, $endingLine);
$this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182 + $additionalMargRight, $endingLine); $this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182 + $additionalMargRight, $endingLine);
@ -330,7 +330,7 @@ class InvoiceGroupPdfHandler extends FPDF
public function DrawArticlesTableValue() public function DrawArticlesTableValue()
{ {
// Set espacement avant de continue // Set espacement avant de continue
$this->SetFont('Arial', '', 10); $this->SetFont('Arial', '', 10);
$devisData = $this->factureData['devis']; $devisData = $this->factureData['devis'];
@ -340,7 +340,7 @@ class InvoiceGroupPdfHandler extends FPDF
$totalTva = 0; $totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 13; $yValue = $this->startingYOfArticlesTable + 13;
// $maxDescriptionWidth = 102; // $maxDescriptionWidth = 102;
$maxDescriptionWidth = 104.3; $maxDescriptionWidth = 104.3;
// $maxDescriptionWidth = 51; // $maxDescriptionWidth = 51;
$currentIndexPosition = $this->currentIndexPosition; $currentIndexPosition = $this->currentIndexPosition;
for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) { for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) {
@ -358,7 +358,7 @@ class InvoiceGroupPdfHandler extends FPDF
$totalTtc += $valueTtc; $totalTtc += $valueTtc;
$productDescription = $product["produit_description"] ?? ""; $productDescription = $product["produit_description"] ?? "";
$currentDevisDefuntName = $currentDevis["defunt_nom"] ?? ""; $currentDevisDefuntName = $currentDevis["defunt_nom"] ?? "";
$dateValue = ""; $dateValue = "";
$dateAndDefuntName = ""; $dateAndDefuntName = "";
if ($productIncrement == 0) { if ($productIncrement == 0) {
@ -407,9 +407,9 @@ class InvoiceGroupPdfHandler extends FPDF
$productIncrement++; $productIncrement++;
} }
$yValue += 6; $yValue += 6;
$isLastLigneDevis = $currentIndexPosition == (($this->initialIndexPosition + $this->devisCountToGet) -1); $isLastLigneDevis = $currentIndexPosition == (($this->initialIndexPosition + $this->devisCountToGet) - 1);
if (!$isLastLigneDevis) { if (!$isLastLigneDevis) {
$this->Line(3, $yValue , 207, $yValue); $this->Line(3, $yValue, 207, $yValue);
} }
} }
$this->currentIndexPosition = $currentIndexPosition; $this->currentIndexPosition = $currentIndexPosition;
@ -467,7 +467,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo(); $this->DrawBankAndTotalPriceInfo();
} }
function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false) public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false)
{ {
// Store reset values for (x,y) positions // Store reset values for (x,y) positions
$x = $this->GetX() + $w; $x = $this->GetX() + $w;
@ -482,19 +482,22 @@ class InvoiceGroupPdfHandler extends FPDF
} }
} }
function NbLines($w, $txt) public function NbLines($w, $txt)
{ {
// Compute the number of lines a MultiCell of width w will take // Compute the number of lines a MultiCell of width w will take
if (!isset($this->CurrentFont)) if (!isset($this->CurrentFont)) {
$this->Error('No font has been set'); $this->Error('No font has been set');
}
$cw = $this->CurrentFont['cw']; $cw = $this->CurrentFont['cw'];
if ($w == 0) if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x; $w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', (string) $txt); $s = str_replace("\r", '', (string) $txt);
$nb = strlen($s); $nb = strlen($s);
if ($nb > 0 && $s[$nb - 1] == "\n") if ($nb > 0 && $s[$nb - 1] == "\n") {
$nb--; $nb--;
}
$sep = -1; $sep = -1;
$i = 0; $i = 0;
$j = 0; $j = 0;
@ -510,21 +513,25 @@ class InvoiceGroupPdfHandler extends FPDF
$nl++; $nl++;
continue; continue;
} }
if ($c == ' ') if ($c == ' ') {
$sep = $i; $sep = $i;
}
$l += $cw[$c]; $l += $cw[$c];
if ($l > $wmax) { if ($l > $wmax) {
if ($sep == -1) { if ($sep == -1) {
if ($i == $j) if ($i == $j) {
$i++; $i++;
} else }
} else {
$i = $sep + 1; $i = $sep + 1;
}
$sep = -1; $sep = -1;
$j = $i; $j = $i;
$l = 0; $l = 0;
$nl++; $nl++;
} else } else {
$i++; $i++;
}
} }
return $nl; return $nl;
} }
@ -534,38 +541,42 @@ class InvoiceGroupPdfHandler extends FPDF
{ {
$k = $this->k; $k = $this->k;
$hp = $this->h; $hp = $this->h;
if ($style == 'F') if ($style == 'F') {
$op = 'f'; $op = 'f';
elseif ($style == 'FD' || $style == 'DF') } elseif ($style == 'FD' || $style == 'DF') {
$op = 'B'; $op = 'B';
else } else {
$op = 'S'; $op = 'S';
}
$MyArc = 4 / 3 * (sqrt(2) - 1); $MyArc = 4 / 3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k));
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $r; $yc = $y + $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k));
if (strpos($corners, '2') === false) if (strpos($corners, '2') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k));
else } else {
$this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc); $this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc);
}
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k));
if (strpos($corners, '3') === false) if (strpos($corners, '3') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r); $this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k));
if (strpos($corners, '4') === false) if (strpos($corners, '4') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc); $this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $r; $yc = $y + $r;
@ -573,8 +584,9 @@ class InvoiceGroupPdfHandler extends FPDF
if (strpos($corners, '1') === false) { if (strpos($corners, '1') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k));
$this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k));
} else } else {
$this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r); $this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r);
}
$this->_out($op); $this->_out($op);
} }

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service; namespace OCA\Gestion\Service;
use DateTime; use DateTime;
use \FPDF; use FPDF;
use OCA\Gestion\Constants\MultipleFactureTypeConstant; use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
@ -35,7 +35,6 @@ use OCA\Gestion\Helpers\PriceHelpers;
class InvoicePdfHandler extends FPDF class InvoicePdfHandler extends FPDF
{ {
private $multipleFactureData = []; private $multipleFactureData = [];
private $factureData = []; private $factureData = [];
private $logo = null; private $logo = null;
@ -49,17 +48,17 @@ class InvoicePdfHandler extends FPDF
private $articleTablesHeight = 130; private $articleTablesHeight = 130;
public $interLigneHeader = 5; public $interLigneHeader = 5;
function Header() public function Header()
{ {
if ($this->logo != "nothing") { if ($this->logo != "nothing") {
$this->Image($this->logoPath . "logo.png", 4, 2, 50, 35); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
$this->AddWatermark(); //$this->AddWatermark();
} else { } else {
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
} }
function AddWatermark() public function AddWatermark()
{ {
try { try {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
@ -67,29 +66,29 @@ class InvoicePdfHandler extends FPDF
$imagePath = $this->logoPath . "filigrane_pdf.png"; $imagePath = $this->logoPath . "filigrane_pdf.png";
list($originalWidth, $originalHeight) = getimagesize($imagePath); list($originalWidth, $originalHeight) = getimagesize($imagePath);
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
$originalWidth = $originalWidth * 0.264583; $originalWidth = $originalWidth * 0.264583;
$originalHeight = $originalHeight * 0.264583; $originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine // Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 1.7; $scale = 1.7;
$width = $originalWidth * $scale; $width = $originalWidth * $scale;
$height = $originalHeight * $scale; $height = $originalHeight * $scale;
// Calculer la position pour centrer l'image // Calculer la position pour centrer l'image
$x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm $x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm
$y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4 $y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4
// Ajouter l'image en filigrane // Ajouter l'image en filigrane
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur $this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
$this->SetAlpha(0.1); // Définir l'opacité $this->SetAlpha(0.1); // Définir l'opacité
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }
function SetAlpha($alpha) public function SetAlpha($alpha)
{ {
// Appliquer la transparence au document // Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255); $this->SetFillColor(255, 255, 255, $alpha * 255);
@ -98,7 +97,7 @@ class InvoicePdfHandler extends FPDF
} }
function Footer() public function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('Arial', '', 7); $this->SetFont('Arial', '', 7);
@ -278,7 +277,7 @@ class InvoicePdfHandler extends FPDF
$this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName); $this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName);
// les traits verticaux colonnes // les traits verticaux colonnes
$additionalMargRight = 1; $additionalMargRight = 1;
$endingLine = $this->thereIsOrderOrCaseNumber ? 231 : 230; // mois +1 pour le groupe $endingLine = $this->thereIsOrderOrCaseNumber ? 231 : 230; // mois +1 pour le groupe
$this->Line(27 + $additionalMargRight, $this->startingYOfArticlesTable, 27 + $additionalMargRight, $endingLine); $this->Line(27 + $additionalMargRight, $this->startingYOfArticlesTable, 27 + $additionalMargRight, $endingLine);
$this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142 + $additionalMargRight, $endingLine); $this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142 + $additionalMargRight, $endingLine);
$this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164 + $additionalMargRight, $endingLine); $this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164 + $additionalMargRight, $endingLine);
@ -331,20 +330,20 @@ class InvoicePdfHandler extends FPDF
if ($product === reset($products)) { if ($product === reset($products)) {
$dateValue = $devisDate; $dateValue = $devisDate;
// $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"]; // $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"];
$this->SetXY(70, $yValue); $this->SetXY(70, $yValue);
$this->Cell(5, 6, $this->factureData["defunt_nom"], 0, 0); $this->Cell(5, 6, $this->factureData["defunt_nom"], 0, 0);
} }
$yValue += 3; $yValue += 3;
$tvaAmount = $valueTtc - $valueHt; $tvaAmount = $valueTtc - $valueHt;
$this->SetXY(5, $yValue + 5); $this->SetXY(5, $yValue + 5);
$this->Cell(5, 6, $dateValue, 0, 0); $this->Cell(5, 6, $dateValue, 0, 0);
$this->SetXY(30, $yValue +5); $this->SetXY(30, $yValue + 5);
$this->MultiAlignCell($maxDescriptionWidth, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', ); $this->MultiAlignCell($maxDescriptionWidth, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', );
$this->SetXY(144, $yValue +5); $this->SetXY(144, $yValue + 5);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C'); $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(165, $yValue + 5); $this->SetXY(165, $yValue + 5);
@ -421,7 +420,7 @@ class InvoicePdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo($totalPriceValue); $this->DrawBankAndTotalPriceInfo($totalPriceValue);
} }
function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false) public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false)
{ {
// Store reset values for (x,y) positions // Store reset values for (x,y) positions
$x = $this->GetX() + $w; $x = $this->GetX() + $w;
@ -436,19 +435,22 @@ class InvoicePdfHandler extends FPDF
} }
} }
function NbLines($w, $txt) public function NbLines($w, $txt)
{ {
// Compute the number of lines a MultiCell of width w will take // Compute the number of lines a MultiCell of width w will take
if (!isset($this->CurrentFont)) if (!isset($this->CurrentFont)) {
$this->Error('No font has been set'); $this->Error('No font has been set');
}
$cw = $this->CurrentFont['cw']; $cw = $this->CurrentFont['cw'];
if ($w == 0) if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x; $w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', (string) $txt); $s = str_replace("\r", '', (string) $txt);
$nb = strlen($s); $nb = strlen($s);
if ($nb > 0 && $s[$nb - 1] == "\n") if ($nb > 0 && $s[$nb - 1] == "\n") {
$nb--; $nb--;
}
$sep = -1; $sep = -1;
$i = 0; $i = 0;
$j = 0; $j = 0;
@ -464,21 +466,25 @@ class InvoicePdfHandler extends FPDF
$nl++; $nl++;
continue; continue;
} }
if ($c == ' ') if ($c == ' ') {
$sep = $i; $sep = $i;
}
$l += $cw[$c]; $l += $cw[$c];
if ($l > $wmax) { if ($l > $wmax) {
if ($sep == -1) { if ($sep == -1) {
if ($i == $j) if ($i == $j) {
$i++; $i++;
} else }
} else {
$i = $sep + 1; $i = $sep + 1;
}
$sep = -1; $sep = -1;
$j = $i; $j = $i;
$l = 0; $l = 0;
$nl++; $nl++;
} else } else {
$i++; $i++;
}
} }
return $nl; return $nl;
} }