Fix watermark alpha transparency (#31535)

This commit is contained in:
John BOTELLA 2024-10-24 13:57:57 +02:00 committed by GitHub
parent 23722b3db8
commit e31adc98fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -814,17 +814,24 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
$watermark_x = $w / 2;
$watermark_y = $h / 3;
$pdf->SetFont('', 'B', 40);
$pdf->SetTextColor(255, 192, 203);
$pdf->SetTextColor(255, 0, 0);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k));
//print watermark
$pdf->SetXY($watermark_x_pos, $watermark_y_pos);
// set alpha to semi-transparency
$pdf->SetAlpha(0.3);
$pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0);
//antirotate
$pdf->_out('Q');
$pdf->SetXY($savx, $savy);
// Restore alpha
$pdf->SetAlpha(1);
}