DV : handle fiilgrane image on pdf if not exit
This commit is contained in:
parent
1f762c759d
commit
9bd15afb8c
@ -68,27 +68,32 @@ class InvoiceGroupPdfHandler extends FPDF
|
|||||||
}
|
}
|
||||||
function AddWatermark()
|
function AddWatermark()
|
||||||
{
|
{
|
||||||
$this->SetAlpha(0.2);
|
try {
|
||||||
|
$this->SetAlpha(0.2);
|
||||||
|
|
||||||
$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
|
||||||
|
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
|
||||||
|
$this->SetAlpha(0.1); // Définir l'opacité
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Ajouter l'image en filigrane
|
|
||||||
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
|
|
||||||
$this->SetAlpha(0.1); // Définir l'opacité
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetAlpha($alpha)
|
function SetAlpha($alpha)
|
||||||
|
|||||||
@ -61,27 +61,32 @@ class InvoicePdfHandler extends FPDF
|
|||||||
|
|
||||||
function AddWatermark()
|
function AddWatermark()
|
||||||
{
|
{
|
||||||
$this->SetAlpha(0.2);
|
try {
|
||||||
|
$this->SetAlpha(0.2);
|
||||||
|
|
||||||
$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
|
||||||
|
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
|
||||||
|
$this->SetAlpha(0.1); // Définir l'opacité
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Ajouter l'image en filigrane
|
|
||||||
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
|
|
||||||
$this->SetAlpha(0.1); // Définir l'opacité
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetAlpha($alpha)
|
function SetAlpha($alpha)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user